Jump to content


Photo

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


  • Please log in to reply
4 replies to this topic

#1 samantha_chan1

samantha_chan1
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 10 April 2006 - 08:41 AM

how can i post a variable let's say $total from 1st page to xx.php while i am using a header("locaiton : xx.php") in 1st page?

#2 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 10 April 2006 - 08:44 AM

Set up a form in the firest page and make a hidden input:
<input type="hidden" name="cheeseopt" value="notliked">
Then on the second script use something like this:
$cheese=$_POST['cheeseopt'];
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.
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#3 samantha_chan1

samantha_chan1
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 10 April 2006 - 08:51 AM

[!--quoteo(post=363221:date=Apr 10 2006, 04:44 PM:name=Yesideez)--][div class=\'quotetop\']QUOTE(Yesideez @ Apr 10 2006, 04:44 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Set up a form in the firest page and make a hidden input:
<input type="hidden" name="cheeseopt" value="notliked">
Then on the second script use something like this:
$cheese=$_POST['cheeseopt'];
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?


#4 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 10 April 2006 - 09:10 AM

Sure is, try this:
header("Location: newscript.php?param=value&param2=value2");
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:
$var1=12;
$var2="text";
header("Location: scripttwo.php?param1=$var1&param2=$var2");

I have to go and do some work now :(

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

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#5 samantha_chan1

samantha_chan1
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 10 April 2006 - 09:22 AM

[!--coloro:#CC66CC--][span style=\"color:#CC66CC\"][!--/coloro--]thanks a lot Yesideez.... you helped me a lot.[!--colorc--][/span][!--/colorc--]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users