Re: session help

From: Date: Wed, 14 May 2003 03:52:27 +0000
Subject: Re: session help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147539@lists.php.net to get a copy of this message
Hi, Wednesday, May 14, 2003, 2:50:45 AM, you wrote: BVB> First crack at sessions and I'm obviously missing something . BVB> I have this at the very top of the page. BVB> $thepassword = 'pass'; BVB> if(isset($_POST['my_button'])) { BVB> if($password) { BVB> if ($password == $thepassword) { BVB> //ini_set("session.use_cookies", "0"); BVB> session_start(); BVB> header("Cache-control: private"); // IE 6 Fix. BVB> $pass = $_POST['password']; BVB> session_register('pass'); BVB> $_SESSION['pass'] = $pass; BVB> } else { BVB> $error_message = "Invalid password, try again"; BVB> } BVB> } else { BVB> $error_message = "You must enter a password"; BVB> } BVB> } BVB> Further down I have these: BVB> if(isset($_SESSION['pass'])) { BVB> if ($_SESSION['pass'] == $thepassword) { BVB> echo "<p style=\"font-weight: bold;\">Add new BVB> record:</p>"; BVB> echo "<FORM METHOD=\"POST\" BVB> ACTION=\"w_insert.php\">"; BVB> echo "Date (yyyy-mm-dd):<input type=\"text\" BVB> name=\"date\">"; BVB> echo "Company:<input type=\"text\" BVB> name=\"company\">"; BVB> echo "Title:<input type=\"text\" BVB> name=\"title\">"; BVB> echo "Actor:</td><td><input type=\"text\" name=\"actor\">></td></tr>"; BVB> echo "Role:</td><td><input type=\"text\" BVB> name=\"role\">"; BVB> echo "<input type=\"SUBMIT\" name=\"do_sql\" BVB> \value=\"S ubmit\">>"; BVB> echo"</FORM>"; BVB> echo "<br><a href=\"w_logout.php?log_out=1\">Log BVB> Out</a><br>"; BVB> } BVB> } elseif (isset($error_message)){ BVB> echo $error_message . ": <a href=\"$PHP_SELF?admin=1\">Try BVB> Again</a>"; BVB> } BVB> if (isset($admin)) { BVB> echo "<FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">"; BVB> //echo "Enter your Name: <input type=\"text\" BVB> name=\"name\">"; BVB> echo "Enter your Password: <input type=\"password\" name=\"password\">>"; BVB> echo "<input type=\"SUBMIT\" name=\"my_button\" BVB> \value=\"Submit\">"; BVB> echo"</FORM>"; BVB> } BVB> Everything here works fine but when I submit the top form above that BVB> calls w_insert.php it does not seem to transfer $_SESSION['pass'] and BVB> perhaps it should not but it seems as though it should, shouldn't it? I BVB> thgought that was the point of sessions... BVB> w_insert.php just contains this for the moment: BVB> <?php BVB> session_start(); BVB> if(isset($_POST['do_sql'])) { BVB> if ($_SESSION['pass'] == $thepassword) { BVB> echo "do sql query"; BVB> } BVB> } ?>> Do you have session_start() on w_insert.php as well? -- regards, Tom

« previous php.general (#147539) next »