I am feeling like a dork today. I can't seem to make my mind work. Anyway I have 3 pages. One sets the session variable to "yes" The second and 3rd check if session is set to yes or not.
If it is not, you are given the chance to set it. I want to do this without going back to page one. So, I thought, okay, make a text box, have user enter a text. I have the code to check the text, the problem is I can either set the session when the text box is show (using include() ) or not.
I can't figure out how to set it if text matches.
I have tried the following:
This is on page 2 and 3, if varset is not = "yes" then you are shown the sessioncheck.php which has the text box and submit button on it.PHP Code:<?php
session_start();
if ($_SESSION['varset'] != "yes") { include 'sessioncheck.php'; }
else{
?>
With this way, the session is set when sessioncheck.php is shown, so it doesn't matter if you enter "text" or "nothing" or what, you have the session. and the page 2 or 3 loads.PHP Code:<?php
session_start();
$_SESSION['varset'] = "yes"
?>
<?php
if($_POST['user']) {
if(($_POST['user'] == "text"));
} else {
?>
This obviously doesn't work, the session is started but the varset is not set to yes, and you go to the 401.shtml page (which implies the varset = "no" but I don't think it is..PHP Code:<?php
session_start();
?>
<?php
if($_POST['user']) {
if(($_POST['user'] == "text"));
$_SESSION['varset'] = "yes";
if(($_POST['user'] != "text"));
$_SESSION['setvar'] = "no";
header('Location: http://mysite.com/401.shtml');
} else {
?>
Any help on what I can do to set the session only if "text" is entered in the text box, and not before, and not if anything is entered in the text box?



Reply With Quote

Bookmarks