kr4mer Posted May 25, 2006 Share Posted May 25, 2006 Hi folks,First of all I'm definitely not a skilled PHP programmer.I have a problem here with session vars.I have 3 pages: page1.php is just a silly login/authentication form (no session there!), in page2.php I collect credentials from page1.php (login password), I check them with a mysql db and I use some user's details to store them into session variables (the idea is to start a session for validated users only).Everything works fine till here. In page2.php I have a search form and I use the information the user types here, together with the value of session vars to create page3.php.Unfortunately although in page3.php I can get the right value of the $_POST variables I cannot get the session vars.If I echo this $_SESSION['FRST_VAR'] I receive an 'Undefined index FRST_VAR' error.Could some of you tell me why is that?Thanks[code]----------------## page2.php#?php>session_start();echo '<script language="JavaScript" src="scriptfile.js"></script>'; /* see down below */// some mysql queries here to validate users and get some information about them$_SESSION['FRST_VAR']=userinfo_1;$_SESSION['SCND_VAR']=userinfo_2;// some html stuff here to make the page less boringecho '<form name="form1" method=POST action="page3.php">';echo 'Data_1:<input type="text" name="box1" size=30>';echo 'Data_2: <input type="text" name="box2" size=30>';echo '<a href="_javascript_:funct_check();">echo '<img name="submitbutton" src="submit.jpg" border=0>';echo '</form>';echo $_SESSION['SCND_VAR']; /* it actually echoes the right userinfo_2 value */?>-------------------## page3.php#?php>session_start();echo $_SESSION['FRST_VAR']; /* Undefined index error comes from here and the similar following one */echo $_SESSION['SCND_VAR'];$info1=$_POST['box1']; /* these have the right values typed in page2.php */$info2=$_POST['box2']; // stuff...?>-------------------## scriptfile.js#function func_check(){ if (document.form1.box1.length==0 && document.form1.box2.length==0) alert('You can't do that!'); else document.form1.submit();}[/code] Link to comment https://forums.phpfreaks.com/topic/10461-error-on-session-variables/ Share on other sites More sharing options...
burhankhan Posted May 26, 2006 Share Posted May 26, 2006 Try to print value of session variable at page2.php and see, thats wrong.[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]## page2.php#?php>session_start();echo '<script language="JavaScript" src="scriptfile.js"></script>'; /* see down below */// some mysql queries here to validate users and get some information about them$_SESSION['FRST_VAR']=userinfo_1;$_SESSION['SCND_VAR']=userinfo_2;echo $_SESSION['FRST_VAR'];echo "<br>"echo $_SESSION['SCND_VAR'][/quote] Link to comment https://forums.phpfreaks.com/topic/10461-error-on-session-variables/#findComment-39153 Share on other sites More sharing options...
kr4mer Posted May 26, 2006 Author Share Posted May 26, 2006 [!--quoteo(post=377270:date=May 26 2006, 05:38 AM:name=burhankhan)--][div class=\'quotetop\']QUOTE(burhankhan @ May 26 2006, 05:38 AM) [snapback]377270[/snapback][/div][div class=\'quotemain\'][!--quotec--]Try to print value of session variable at page2.php and see, thats wrong.[/quote]actually I did it and apparently their value is what I set few lines above. Link to comment https://forums.phpfreaks.com/topic/10461-error-on-session-variables/#findComment-39166 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.