Hi

 

I have a problem using http component posting parameters to log into a PHP
application.

 

If I can log to using  IE writing in the url area the following string:

 

http://localhost:9090/index.php?c=login/login
<http://localhost:9090/index.php?c=login/login&username=cnsp12&password=cnsp
12> &username=cnsp12&password=cnsp12

 

 

Using HTTP component with the following code I have no success indeed I
can't log to the application receiving from the server the message "No right
for this operation"

 

procedure  NkCloseRip;

var

    DataIn  : TMemoryStream;

    DataOut : TMemoryStream;

    Buf,     : String;

    http     : THttpCli;

    mYres  : TStringlist;

begin

     DataIn  := TMemoryStream.Create;  { For the response        }

    DataOut := TMemoryStream.Create;  { For the data to be sent }

     mYres:=TStringlist.Create;

     http    := THttpCli.Create(nil);

      { Build the data to be sent to the CGI. }

        Buf     := 'c='+encode('login/login') +

                   '&username=' +encode('cnsp12') +

                   '&password=' + encode('cnsp12')+ 

                   '&Invia=' + encode('Invia');

        { Write the data to the stream which will be used to send }

        DataOut.Write(Buf[1], Length(Buf));

        { Position the stream at the beginning or nothing will be sent }

        DataOut.Seek(0, soFromBeginning);

 

        { Setup the HTTP component to transmit }

        http.SendStream := DataOut;

        http.RcvdStream := DataIn;

 

        Http.URL        :=  'http://localhost:9090/index.php'; ;

         try

 

                http.Post;

                { Data sent, copy the webserver response to the DisplayMemo
}

                DataIn.Seek(0, 0);

                 myres.LoadFromStream(DataIn);

           

            except

                { An error occured ! }

               Showmessage('HTTP Failed : ' + Http.ReasonPhrase);

               

            end;

        DataOut.Free;

        DataIn.Free;

   

end;

 

 

What is wrong?

 

Regards

Rocco Neri

 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to