wizzy886 Posted October 28, 2013 Share Posted October 28, 2013 So i have the problem where the registration was working before, but now isn't and now it isn't. On top of this the actual login doesn't work either. I honestly don't know what is wrong with it so can i please have some guidance. I have troubleshot all of that I know how to and tried to output any error messages but fail in doing so. Thanks. index.php login.php register.php connection.php footer.php header.php Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 28, 2013 Share Posted October 28, 2013 (edited) you need to tell us what you found when you were troubleshooting the problem. in what file and at what line/statement did you find that the code was not doing what you expected and what exact symptom are you getting and at what point during the process that leads you to believe the process isn't doing what you expect? Edited October 28, 2013 by mac_gyver Quote Link to comment Share on other sites More sharing options...
wizzy886 Posted October 28, 2013 Author Share Posted October 28, 2013 (edited) Sorry, It basically looks like its submitting something (in both registration and login). After this nothing. Ive tried to output the results of the script throughout its process with little luck. The main problems are in registration and login if you could give them a look over please. Im sure its something ive just missed. Edited October 28, 2013 by wizzy886 Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 28, 2013 Share Posted October 28, 2013 (edited) the only things that are apparent in your code is there isn't a session_start() statement, so the login won't actually remember the logged in state, but registration should work, and the use of or trigger_error() as error handling logic doesn't address the execution path your code takes, and is dependent on php's error_reporting/display_errors settings, so your code could have database errors, but you might never know it. what does adding the following two lines, immediately after the first opening <?php tag in your register.php page, show - ini_set("display_errors", "1"); error_reporting(-1); Edited October 28, 2013 by mac_gyver Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted October 28, 2013 Solution Share Posted October 28, 2013 On line 20 in register.php you should be assigning the username to $username not $password $password = mysqli_real_escape_string($dbc, $trimmed['username']); In login.php you are not using sessions properly echo "success"; session_start(); $_SESSION['username'] = mysqli_fetch_array($r, MYSQLI_ASSOC); sesssion_start() should be called before you ouput anything to the browser. I recommend putting it on line 1 of header.php To set the username data to the session you need to do $row = mysqli_fetch_array($r, MYSQLI_ASSOC); $_SESSION['username'] = $row['username']; $_SESSION['user_id'] = $row['user_id']; $_SESSION['user_level'] = $row['user_level']; Quote Link to comment 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.