Jump to content

Archived

This topic is now archived and is closed to further replies.

samantha_chan1

*SOLVED* post varible in header (location:xx.php)

Recommended Posts

Set up a form in the firest page and make a hidden input:
[code]<input type="hidden" name="cheeseopt" value="notliked">[/code]
Then on the second script use something like this:
[code]$cheese=$_POST['cheeseopt'];[/code]
Use $_POST if in your form you use method="post" and $_GET if you use method="get"

The difference is POST sends the form data in a packet whereas GET adds the form data onto the end of the URL and sends it that way - POST is more secure.

Share this post


Link to post
Share on other sites
[!--quoteo(post=363221:date=Apr 10 2006, 04:44 PM:name=Yesideez)--][div class=\'quotetop\']QUOTE(Yesideez @ Apr 10 2006, 04:44 PM) [snapback]363221[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Set up a form in the firest page and make a hidden input:
[code]<input type="hidden" name="cheeseopt" value="notliked">[/code]
Then on the second script use something like this:
[code]$cheese=$_POST['cheeseopt'];[/code]
Use $_POST if in your form you use method="post" and $_GET if you use method="get"

The difference is POST sends the form data in a packet whereas GET adds the form data onto the end of the URL and sends it that way - POST is more secure.
[/quote]

But i am posting the variable in a script to another page. the script is not in the html. so i can't but a hidden field in it. does there have any other solution?

Share this post


Link to post
Share on other sites
Sure is, try this:
[code]header("Location: newscript.php?param=value&param2=value2");[/code]
Then in the second script use $_REQUEST to get the contents of param and param 2 and so on.
If you need help building the URL for the header() function something like this would work:
[code]$var1=12;
$var2="text";
header("Location: scripttwo.php?param1=$var1&param2=$var2");[/code]

I have to go and do some work now :(

Just for information, here is how you would read the vars in the second script:
[code]$var1=$_REQUEST['param1'];
$var2=$_REQUEST['param2'];[/code]
Hope you get it sorted ;)

Share this post


Link to post
Share on other sites
[!--coloro:#CC66CC--][span style=\"color:#CC66CC\"][!--/coloro--][b]thanks a lot Yesideez.... you helped me a lot.[!--colorc--][/span][!--/colorc--][/b]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.