SNN Posted April 24, 2007 Share Posted April 24, 2007 I have tried multiple ways of using a session and a form, no luck at all. Can anyone tell me how to properly use the code? 1st time if($_SESSION['user'] == "user" AND $_SESSION['pass'] == "pass") 2nd time if($_SESSION['user'] == "user" && $_SESSION['pass'] == "pass") 3rd time if($_SESSION['user'] == "user") { if($_SESSION['pass'] == "pass") Oh and if this has anything to do with it, I have 4 things running on if/elseif. Thanks for any help Link to comment https://forums.phpfreaks.com/topic/48384-solved-need-help-with-a-session-and-form-thing/ Share on other sites More sharing options...
bobleny Posted April 24, 2007 Share Posted April 24, 2007 uh, they all should work, but are you aware that forms use $_POST['data'] not sessions? If you are coming from a form, then unless you convert the form POST data to SESSION data, that wont work... Edit: Heres an example. Your form: <form action="" method=""> <input type="text" name="user" /> <input type="password" name="pass" /> <input type="submit" value="Submit" /> </form> The PHP: If ($_POST['user'] == "George" && $_POST['pass'] == "s3Cr3t") { echo "You entered George as a username and s3Cr3t as a password"; } Link to comment https://forums.phpfreaks.com/topic/48384-solved-need-help-with-a-session-and-form-thing/#findComment-236571 Share on other sites More sharing options...
SNN Posted April 24, 2007 Author Share Posted April 24, 2007 The script uses sessions, it was working before I added in more users/passes then it just started falling apart. It only uses $_POST to say that they entered a invalid user/pass. I may just have to rewrite the script, because now it's giving me a unexpected $ error, which there is nothing there, so it's just messing up. Good thing it takes like 5 minutes.. I guess I'll post what I get after I rewrite the users section of the script. Link to comment https://forums.phpfreaks.com/topic/48384-solved-need-help-with-a-session-and-form-thing/#findComment-236572 Share on other sites More sharing options...
SNN Posted April 24, 2007 Author Share Posted April 24, 2007 That's weird, that's the exact type of form I set up. :-\ I may just convert it over to a PHP and MySQL system, that would work a LOT better, I bet... especially for the posting system I am adding onto it. I can do the MySQL coding, thanks for the help uh, they all should work, but are you aware that forms use $_POST['data'] not sessions? If you are coming from a form, then unless you convert the form POST data to SESSION data, that wont work... Edit: Heres an example. Your form: <form action="" method=""> <input type="text" name="user" /> <input type="password" name="pass" /> <input type="submit" value="Submit" /> </form> The PHP: If ($_POST['user'] == "George" && $_POST['pass'] == "s3Cr3t") { echo "You entered George as a username and s3Cr3t as a password"; } Link to comment https://forums.phpfreaks.com/topic/48384-solved-need-help-with-a-session-and-form-thing/#findComment-236615 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.