Forum Moderators: open

Message Too Old, No Replies

Simulating a "SUBMIT" button

What is the HTTP request?

         

trillianjedi

11:36 am on Aug 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need to build a small linux app that simulates a user filling in a form and clicking a "submit" button (I need to parse the returned page).

I'm not sure what my http request would be.

The pages form is basically:-

<FORM action="index.php" method="POST">

and two edit boxes (called "username" and "password").

So I need to build a string that represents the http string sent to the server on clicking the button.

I'm guessing it will be something along the lines of:-

[domain.com...]

But I'm not sure exactly how forms work in HTTP (the above example didn't work).

Thanks,

TJ

Yidaki

11:58 am on Aug 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure if i understand what you are trying to do here, tj - but if your form's method is POST (rather than GET), the variables won't come in the url but in the (invisible) HTTP Header.

So if you use php to parse the result you should use either of both methods:

for POST forms (/index.php):

$username=$HTTP_POST_VARS{'username'};
$password=$HTTP_POST_VARS{'password'}

for GET forms (/index.php?username=tj&password=WebmasterWorld):

$username=$HTTP_GET_VARS{'username'};
$password=$HTTP_GET_VARS{'password'}

HTH

trillianjedi

12:17 pm on Aug 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yup, that's it Yidaki - many thanks!

TJ

trillianjedi

12:25 pm on Aug 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm... maybe not - now I'm getting a 400 error back.

<Edit>It's ok - I worked it out. I had missed a hidden field on the form..... my original idea of :-

[domain.com...]

was in fact correct, I had just missed putting in the hidden text field as a variable</Edit>

TJ