Jump to content

Session


sweinkauf13

Recommended Posts

Hey. I really need some help. This is my php code. I'm not sure why it doesn't execute. It will come up as a blank page and won't redirect anywhere. IT DOES NOTHING!!! :) Please help

<?If(($_POST[username] == " ") ||   ($_POST[password] == " ")){header("login.phtml");exit;}else if(($_POST[username] != "sweinkauf13") ||		  ($_POST[password] != "48507")){header("login.phtml");exit;}else if(($_POST[username] == "sweinkauf13") &&   ($_POST[password] == "48507")){//they are valid now//start the session and insert the username and passward data//then send them to the homepagesession_start();$_SESSION['username'] = $_POST[username];$_SESSION['password'] = $_POST[password];header("home.phtml");exit;}?>

If you need anything else let me know. Thanks a ton.youngwebmaster

Link to comment
Share on other sites

Debug. Do the following one at a time and run the code after each one. 1. Add a line at the top of the code: echo "hello"; That'll tell you if it's parsing.2. Add another line at the top. var_dump ($_POST); now you'll know what's coming in. It might not be what you think.3. Add a plain else (not an else if) at the bottom of the code. echo "bad data";You can pull all these out later on.4. Think about this: $_POST[username] == " " I assume you're looking for a null string, but this has a space character in it. Take it out? The password test has one also.

Link to comment
Share on other sites

In addition to what Dad said, you're using the header function wrong. You don't just send a filename to the header function. The header function sends an HTTP header, and there's no HTTP header that's just a filename. You have to say what header it is. If you want to redirect, it's a location header.header("Location: login.phtml");

Link to comment
Share on other sites

thanks you justsomeguy. The header() function was my problem. And thank you dd for replying on this topic with those debug steps. I will definitly use those when i have another problem. angain thanks to all,youngwebmaster

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...