Variables persistent through two pages
Moderator: General Moderators
Variables persistent through two pages
Hi,
I'm trying to get a variable across multiple pages, and right now it's not working. I'm trying to build a login feature where the user enters their username and password, then a TOS page appears, and then, if they accept the terms, are logged in. Right now, the problem I have is that going from the TOS page to logging them in is on a different page, and the variables that need to be checked are lost when changing pages. Is there anyone who know how I could move the variables with the page? I've considered cookies, but I've never used them, and it seems like a lot of work for such a (seemingly) simple task.
Thanks for any input
Sphenn
I'm trying to get a variable across multiple pages, and right now it's not working. I'm trying to build a login feature where the user enters their username and password, then a TOS page appears, and then, if they accept the terms, are logged in. Right now, the problem I have is that going from the TOS page to logging them in is on a different page, and the variables that need to be checked are lost when changing pages. Is there anyone who know how I could move the variables with the page? I've considered cookies, but I've never used them, and it seems like a lot of work for such a (seemingly) simple task.
Thanks for any input
Sphenn
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
use session data: session_start()
-
shwetha004
- Forum Newbie
- Posts: 12
- Joined: Mon Aug 06, 2007 10:39 pm
hi evryone!!
im kinda new to php,and im developing an online banking system.
i have the same question as Sphenn,and i have tried the solutions suggested in this thread.i am attempting to use the session method to retain a variable value across 2 forms.but somehow im not getting the desired output
i have 3 pages..the 1st page basically allows users to input their particular.the variable which i want to retain is in this page,input thru a field called nric.
the second page has some php which checks the fields.i want to retain the nric value from page 1,and pass it to page3..
in my second page,i have this codeand in my 3rd page i have:
so the 3rd page is supposed to display the nric that was input in the 1st page.but somehow the value is lost..im not sure why this is happening.if anyone could point out wer is my mistake,that would b great.maybe there is some error in my code...
thank you..
im kinda new to php,and im developing an online banking system.
i have the same question as Sphenn,and i have tried the solutions suggested in this thread.i am attempting to use the session method to retain a variable value across 2 forms.but somehow im not getting the desired output
i have 3 pages..the 1st page basically allows users to input their particular.the variable which i want to retain is in this page,input thru a field called nric.
the second page has some php which checks the fields.i want to retain the nric value from page 1,and pass it to page3..
in my second page,i have this code
Code: Select all
$ic= $_POST['nric'];
session_register();
session_start();
$_SESSION['ic'] =$_POST['nric'];Code: Select all
session_start();
echo "ic num is:".$_SESSION['ic'];thank you..
-
shwetha004
- Forum Newbie
- Posts: 12
- Joined: Mon Aug 06, 2007 10:39 pm
hi all...
i switched to hidden fields to achieve the same effect..
so now my page1.php has:
the reason im including the form in a php script is,i only want this part of the form to be displayed after certain validation is done.
and my page 2.php has:
im trying to just output the hidden file value..to check whether it gets passed..
but apparently it doesnt,[s]coz[/s] because im getting an empty space..
i have narrowed down the problem to:my guess is, since that coding is already in an echo statement starting with ', so somehow all the single n double quotes are conflicting.
and i have tried using different combinations of single n double quotes,but none of it is working.and when i attempt to insert the $ic variable into my database,the value that is saved is: <?php echo $ic;?>.maybe only using quotes is not enough..what about slashes?.im really stumped..cant figure out how to get over this..would be very grateful if anyone can point me in the right direction.
thank you so much
i switched to hidden fields to achieve the same effect..
so now my page1.php has:
Code: Select all
echo '
<input type="hidden" id="icNum" name="icNum" value="<?php echo $ic;?>" > ' ;and my page 2.php has:
Code: Select all
$ic = $_POST['icNum'];
echo "Ic num from hidden field:".$ic;but apparently it doesnt,[s]coz[/s] because im getting an empty space..
i have narrowed down the problem to:
Code: Select all
value="<?php echo $ic;?>"thank you so much
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.
Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.
-
shwetha004
- Forum Newbie
- Posts: 12
- Joined: Mon Aug 06, 2007 10:39 pm
hello all..
first of all,sorry about the AOL speak..i will avoid it in future..anyway,i managed to solve the problem..
instead of printing the whole form in a php echo statement,i kind of separated the code into different chunks,some html,some php..so,now my code reads:
then to perform some database functions,i start the php code with <?php again..
maybe this is not the most efficient way,but at least its working..if anyone can show me a better wat to do it,i'll be happy to learn..
first of all,sorry about the AOL speak..i will avoid it in future..anyway,i managed to solve the problem..
instead of printing the whole form in a php echo statement,i kind of separated the code into different chunks,some html,some php..so,now my code reads:
Code: Select all
//some validation
//if the validation is successfull,the next part of the form will be displayed.
?>Code: Select all
*i placed all the html code here..to display the form.maybe this is not the most efficient way,but at least its working..if anyone can show me a better wat to do it,i'll be happy to learn..