Http request with Post

Just starting out? Need help? Post your questions and find answers here.
atlante
Posts: 8
Joined: Thu Apr 16, 2015 10:24 am

Http request with Post

Post by atlante »

Hello guys,

Could you tell me why i'm unable to have a value sent by post ?

Spider file :

Code: Select all

Procedure GadgetEvents()
  If EventGadget() = 0 And EventType() = #PB_EventType_RightClick
    Debug "here"
    DisplayPopupMenu(0, WindowID(0))
  EndIf
EndProcedure


Procedure MenuEvents()
  Debug EventMenu()  ; To see which menu has been selected
EndProcedure

Procedure HttpGetEvent(Success, Result$)
  Protected i
 
  If Success
   
    AddGadgetItem(0, -1,  Result$)
   
   
  Else
    AddGadgetItem(0, -1,  "HTTPRequest(): Error")
  EndIf
EndProcedure



;
If OpenWindow(0, 100, 100, 300, 260, "Request test", #PB_Window_TitleBar)

  ListIconGadget(0, 10, 10, 280, 240, "The test", 200)
    AddGadgetItem(0, -1, "Test value")
    HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/post_request.php", "hello=tttt&hello2=yyyyy", @HttpGetEvent())
        
  BindEvent(#PB_Event_Menu, @MenuEvents())
  BindEvent(#PB_Event_Gadget, @GadgetEvents())
EndIf
Php file :

Code: Select all

<?php
 
foreach($_POST as $name => $value)
{
  echo $name;
}
                    
?>
thanks
Fred
Site Admin
Posts: 1821
Joined: Mon Feb 24, 2014 10:51 am

Re: Http request with Post

Post by Fred »

You need to use #PB_HTTP_Post instead of #PB_HTTP_Get
atlante
Posts: 8
Joined: Thu Apr 16, 2015 10:24 am

Re: Http request with Post

Post by atlante »

Fred wrote:You need to use #PB_HTTP_Post instead of #PB_HTTP_Get
Damn it ! I was very tired. Thanks again Fred.


@all : I wish all of you a Merry Christmas !

Atlante
Post Reply