Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Error on session vars
Old 05-24-2006, 02:22 PM Error on session vars
Junior Talker

Posts: 1
Trades: 0
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.
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['1ST_VAR'] I receive an 'Undefined index 1ST_VAR' error.
Could some of you tell me why is that?
Thanks.

----------------
#
# 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['1ST_VAR']=userinfo_1;
$_SESSION['2ND_VAR']=userinfo_2;

// some html stuff here to make the page less boring

echo '<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['2ND_VAR']; /* it actually echoes the right userinfo_2 value */
?>

-------------------
#
# page3.php
#
?php>
session_start();

echo $_SESSION['1ST_VAR']; /* Undefined index error comes from here and the similar following one */
echo $_SESSION['2ND_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();
}
kr4mer is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-27-2006, 03:27 PM Re: Error on session vars
ChancesAre's Avatar
Skilled Talker

Posts: 84
Trades: 0
Must be the problems. Where is userinfo_1 and userinfo_2 comming from? Should they be $userinfo_1 or are they defined?

Quote:
Originally Posted by kr4mer
----------------
#
# 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['1ST_VAR']=userinfo_1;
$_SESSION['2ND_VAR']=userinfo_2;

// some html stuff here to make the page less boring

echo '<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['2ND_VAR']; /* it actually echoes the right userinfo_2 value */
?>

-------------------
#
# page3.php
#
?php>
session_start();

echo $_SESSION['1ST_VAR']; /* Undefined index error comes from here and the similar following one */
echo $_SESSION['2ND_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();
}
ChancesAre is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Error on session vars
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10892 seconds with 12 queries