mrwizard Posted June 1, 2011 Share Posted June 1, 2011 i have this code in a form, i need to pass a variable $time to next page, how can i do that ? if( $sErr ) print "<script language='javascript' type='text/javascript'>location.href='#error';</script>";;; else: print "<script language='javascript' type='text/javascript'>location.href='paypal.php';</script>";;; Quote Link to comment https://forums.phpfreaks.com/topic/238130-passing-variable-to-new-page/ Share on other sites More sharing options...
xyph Posted June 1, 2011 Share Posted June 1, 2011 Check out PHP Sessions. Quote Link to comment https://forums.phpfreaks.com/topic/238130-passing-variable-to-new-page/#findComment-1223636 Share on other sites More sharing options...
eMonk Posted June 1, 2011 Share Posted June 1, 2011 You can do this with $_POST $time = trim($_POST['time']); Quote Link to comment https://forums.phpfreaks.com/topic/238130-passing-variable-to-new-page/#findComment-1223640 Share on other sites More sharing options...
xyph Posted June 1, 2011 Share Posted June 1, 2011 Keep in mind, anything transferred by POST or GET can be modified by the user. Quote Link to comment https://forums.phpfreaks.com/topic/238130-passing-variable-to-new-page/#findComment-1223646 Share on other sites More sharing options...
mrwizard Posted June 2, 2011 Author Share Posted June 2, 2011 You can do this with $_POST $time = trim($_POST['time']); Thnx for the reply. I've been using the method like >> paypal.php?time=$time which doesn't work here, is there a work around to use it with java script like in my case ? I am trying the post method. Quote Link to comment https://forums.phpfreaks.com/topic/238130-passing-variable-to-new-page/#findComment-1223946 Share on other sites More sharing options...
revraz Posted June 2, 2011 Share Posted June 2, 2011 Why not use a session variable? Quote Link to comment https://forums.phpfreaks.com/topic/238130-passing-variable-to-new-page/#findComment-1223952 Share on other sites More sharing options...
arup.senapati Posted June 2, 2011 Share Posted June 2, 2011 You can do it through JavaScript Function function goto(val){ self.location="ww.paypal.com?time="+val } in you php code you can call the function like: <a href="javascript:goto('<?php print $time; ?>')">click me </a> Quote Link to comment https://forums.phpfreaks.com/topic/238130-passing-variable-to-new-page/#findComment-1223958 Share on other sites More sharing options...
revraz Posted June 2, 2011 Share Posted June 2, 2011 What if the user turns off JS? Quote Link to comment https://forums.phpfreaks.com/topic/238130-passing-variable-to-new-page/#findComment-1223962 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.