Re: Re: session help

From: Date: Tue, 13 May 2003 20:11:35 +0000
Subject: Re: Re: session help
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-147486@lists.php.net to get a copy of this message
On Tue, 2003-05-13 at 13:07, Joe Van Meer wrote: > Hi there, > > I believe session_start() has to be at the top of the PHP page. > I am doing that. > Cheers, Joe > > > "Brian V Bonini" <b-bonini@cox.net> wrote in message > news:1052844644.1368.14.camel@gfxdesign... > > First crack at sessions and I'm obviously missing something . > > > > I have this at the very top of the page. > > > > $thepassword = 'pass'; > > > > if(isset($_POST['my_button'])) { > > if($password) { > > if ($password == $thepassword) { > > //ini_set("session.use_cookies", "0"); > > session_start(); > > header("Cache-control: private"); // IE 6 Fix. > > $pass = $_POST['password']; > > session_register('pass'); > > $_SESSION['pass'] = $pass; > > } else { > > $error_message = "Invalid password, try again"; > > } > > } else { > > $error_message = "You must enter a password"; > > } > > } > > > > Further down I have these: > > > > if(isset($_SESSION['pass'])) { > > if ($_SESSION['pass'] == $thepassword) { > > echo "<p style=\"font-weight: bold;\">Add new > > record:</p>"; > > > > echo "<FORM METHOD=\"POST\" > > ACTION=\"w_insert.php\">"; > > echo "Date (yyyy-mm-dd):<input type=\"text\" > > name=\"date\">"; > > echo "Company:<input type=\"text\" > > name=\"company\">"; > > echo "Title:<input type=\"text\" > > name=\"title\">"; > > echo "Actor:</td><td><input type=\"text\" > > name=\"actor\"></td></tr>"; > > echo "Role:</td><td><input type=\"text\" > > name=\"role\">"; > > echo "<input type=\"SUBMIT\" name=\"do_sql\" > > \value=\"S > > ubmit\">"; > > > > echo"</FORM>"; > > echo "<br><a href=\"w_logout.php?log_out=1\">Log > > Out</a><br>"; > > } > > } elseif (isset($error_message)){ > > echo $error_message . ": <a href=\"$PHP_SELF?admin=1\">Try > > Again</a>"; > > } > > > > > > if (isset($admin)) { > > echo "<FORM METHOD=\"POST\" > > ACTION=\"$PHP_SELF\">"; > > //echo "Enter your Name: <input type=\"text\" > > name=\"name\">"; > > echo "Enter your Password: <input type=\"password\" > > name=\"password\">"; > > echo "<input type=\"SUBMIT\" name=\"my_button\" > > \value=\"Submit\">"; > > echo"</FORM>"; > > } > > > > Everything here works fine but when I submit the top form above that > > calls w_insert.php it does not seem to transfer $_SESSION['pass'] and > > perhaps it should not but it seems as though it should, shouldn't it? I > > thgought that was the point of sessions... > > > > w_insert.php just contains this for the moment: > > > > <?php > > session_start(); > > if(isset($_POST['do_sql'])) { > > if ($_SESSION['pass'] == $thepassword) { > > echo "do sql query"; > > } > > } > > ?> > > > > > >

« previous php.general (#147486) next »