Jump to content

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


samantha_chan1

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.
Link to comment
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?
Link to comment
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 ;)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.