White_Lily Posted December 4, 2012 Share Posted December 4, 2012 (edited) Hi, I have a problem in which I have validation that allows a user to sign into their account if they didn't provide an email address upon registration (which when they do provide an email address they get sent a generated password in their welcome email). Once they manage to sign in without the password they will get directed to a page where they will be asked to create one. However when this process happens it does not log them in, it just comes up with an Internal Server Error. My code is below: if(!empty($_POST["login"])){ $logUser = $_POST["logUser"]; $logPass = $_POST["logPass"]; if(empty($logUser)){ $logErr .= "<li class='error'>You can't sign in without providing your registered username.</li>"; } $grabUserData = select("username, password", "users", "username = '$logUser'"); $data = mysql_fetch_assoc($grabUserData); if($data["username"] != $logUser){ $logErr .= "<li class='error'>Invalid username</li>"; } if(empty($logPass) && $data["password"] == "da39a3ee5e6b4b0d3255bfef95601890afd80709"){ session_start(); $_SESSION["UserProfile"] = $logUser; $_SESSION["UserID"] = $data["user_id"]; header("profile.php"); } } Any ideas would be useful. - Lily (I don't want posts about the security of my processing code... if I wanted opinions on this I would ask.) Edited December 4, 2012 by White_Lily Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/ Share on other sites More sharing options...
MDCode Posted December 4, 2012 Share Posted December 4, 2012 I really can not tell what your code is about. Which page is this referring to? Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397459 Share on other sites More sharing options...
White_Lily Posted December 4, 2012 Author Share Posted December 4, 2012 val.php... where all the validation for the site goes. the user enters data into the login area on the home page, which then gets passed through val.php (above) which if successful redirects to profile.php... Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397460 Share on other sites More sharing options...
MDCode Posted December 4, 2012 Share Posted December 4, 2012 I noticed a few things that seem rather odd. You are checking if $logUser is empty but querying anyways. (not the issue I guess). I have no idea what could be causing the 500 error unless the function select() has something to do with it. Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397461 Share on other sites More sharing options...
White_Lily Posted December 4, 2012 Author Share Posted December 4, 2012 it can't be the select function because most of the site usues it and they all work fine and done the same way as above. Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397462 Share on other sites More sharing options...
MDCode Posted December 4, 2012 Share Posted December 4, 2012 Try putting a die; after your header Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397464 Share on other sites More sharing options...
PFMaBiSmAd Posted December 4, 2012 Share Posted December 4, 2012 (edited) If you are getting a HTTP 500 Internal Server Error on a .php page it usually means that you are getting a fatal parse or a fatal runtime error. You should be developing and debugging your code with php's error_reporting set to E_ALL and display_errors set to ON, so that php will report and display all the errors it detects. The snippet of posted code doesn't produce a fatal parse error. We cannot possibly help you with a HTTP 500 Internal Server Error without A) the code for the entire page, including any included/required files (less any database connection information) and B) the php detected errors on the page. Edited December 4, 2012 by PFMaBiSmAd Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397465 Share on other sites More sharing options...
White_Lily Posted December 4, 2012 Author Share Posted December 4, 2012 It wasn't a HTTP 500... Re-read my post and you'll see its an "Internal Server Error", nothing about http 500... Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397472 Share on other sites More sharing options...
White_Lily Posted December 4, 2012 Author Share Posted December 4, 2012 Ah, I have figured it, i forgot to write "Location: ..."; and also needed the die; for some reason... (don't usually need die;) Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397473 Share on other sites More sharing options...
MDCode Posted December 4, 2012 Share Posted December 4, 2012 (edited) Internal Server Error is really called an HTTP 500 Internal Server Error. They are the same Overlooked your header completely. And die; prevents the rest of the script from executing Edited December 4, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397474 Share on other sites More sharing options...
White_Lily Posted December 4, 2012 Author Share Posted December 4, 2012 (edited) If they are the same, then please explain why enabling the php.ini file does not display errors on one Internal Server Error, whereas HTTP 500 does display errors? I know what die; does, im just saying that I don't usually need it. Edited December 4, 2012 by White_Lily Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397476 Share on other sites More sharing options...
MDCode Posted December 4, 2012 Share Posted December 4, 2012 (edited) I don't think that the Internal Server Error will allow the displaying of errors. Edited December 4, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397478 Share on other sites More sharing options...
White_Lily Posted December 4, 2012 Author Share Posted December 4, 2012 Well then they aren't the same lol Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397479 Share on other sites More sharing options...
MDCode Posted December 4, 2012 Share Posted December 4, 2012 Yes...they are. Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397481 Share on other sites More sharing options...
Christian F. Posted December 4, 2012 Share Posted December 4, 2012 http://pcsupport.about.com/od/findbyerrormessage/a/500servererror.htm Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397571 Share on other sites More sharing options...
Jessica Posted December 5, 2012 Share Posted December 5, 2012 You were told many times before to always use die() after a header, and you keep arguing against using it. I hope you finally realize you can actually change your practices for the better. Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397624 Share on other sites More sharing options...
Jessica Posted December 5, 2012 Share Posted December 5, 2012 Edit: header location call. Quote Link to comment https://forums.phpfreaks.com/topic/271589-login-help/#findComment-1397626 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.