I've been doing some testing with PHP sessions. I've got a page set up where if there is no session, it automatically redirects you to my homepage. However, it does that every time. I can't figure out how to send the set session from the form to that page in order to show it that it has been set. How would I do this?
$_SESSION['foobar'] = true;
// rest of page . . .
if(empty($_SESSION['foobar']) or $_SESSION['foobar'] != true)
// rest of page . . .
But I only want the session to be set if the form is submitted. I don't want it set as soon as a user goes to the homepage.
((sorry for the double post; can't edit the last one at this point))
I was able to figure my last question out on my own. But for some reason, in the test page for the session, none of the CSS is working. What's up with that?
No way to tell without seeing it. Might be a good idea to start by running the page through the HTML validator and CSS Validator pages.
That's the form page to create the session, and it's doing the same thing. I have the background color in the CSS set to #000000 (black). That stylesheet works on all of my other pages that I use it on, so I don't understand why it doesn't work on this one.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN">
<title>Session Test Form</title>
<LINK href="css/general.css" rel="stylesheet" type="text/css">
<form id="test" name="test" method="post" action=" ">
<input type="text" id="username" name="username" cols="40"> <br>
<input type="text" id="password" name="password" cols="40"> <br> <br>
<input type="submit" id="submit" name="submit" value="Submit Form"><img src="spacer.gif" width="5" height="1" alt="Submit">
<input type="reset" id="reset" name="reset" value="Clear Form">
Is it in the same directory as the other files that work? I ask because you use a relative path to the CSS file in your link tag.
edit: sorry didn't realise you answered your last question
It's not in the same directory as the form and session test page that I'm experimenting with. It's in my CSS directory (where I keep all of my stylesheets). To get to the pages I'm testing, you have to go to domain.com/news/page.php. The CSS directory is in the main site root.
Make the href value an absolute site path by prepending a "/", then it won't matter where the page using it is in the directory structure:
<LINK href="/css/general.css" rel="stylesheet" type="text/css">
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)