Page 1 of 1

Http request with Post

Posted: Fri Dec 23, 2016 4:50 pm
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

Re: Http request with Post

Posted: Sat Dec 24, 2016 7:24 am
by Fred
You need to use #PB_HTTP_Post instead of #PB_HTTP_Get

Re: Http request with Post

Posted: Sat Dec 24, 2016 1:45 pm
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