jukie Posted June 17, 2013 Share Posted June 17, 2013 Hi I posted this in another forum but this might be better in here, I just cant seem to get my login to check the username and password to let the user enter the webpage I get no errors, just that the index pages keeps reloading on submit. This is my MySQL code <?php $host = ''; $user = ''; $password = ''; $database = ''; $conn = mysql_connect($host,$user,$password) or die('Server Information is not Correct'); mysql_select_db($database,$conn) or die('Database Information is not correct'); // Inialize session session_start(); // Include database connection settings // Retrieve username and password from database according to user's input $login = mysql_query("SELECT * FROM gotusers WHERE (Username = '" . mysql_real_escape_string($_POST['Username']) . "') and (Password = '" . mysql_real_escape_string(md5($_POST['Password'])) . "')"); // Check username and password match if (mysql_num_rows($login) == 1) { // Set username session variable $_SESSION['Username'] = $_POST['Username']; // Jump to secured page header('Location: sucess.php'); } else { // Jump to login page header('Location: index.php'); } ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted June 17, 2013 Share Posted June 17, 2013 Then you are either finding no match or more than 1 match. Always put the query string into a variable so you can echo it if required. $sql = "SELECT foo FROM bar"; $result = mysql_query($sql); In cases like this you can now echo $sql then copy and paste the actual query into phpMyAdmin (or similar) and see what the results are Quote Link to comment Share on other sites More sharing options...
jukie Posted June 17, 2013 Author Share Posted June 17, 2013 Thanks, I got the login in by changing the query. What is annoying me is that I had all this working in local, the register page is not even working either, or the sessions, now uploaded it to web and none of it working. Seems there no point in working locally if the codes don't work when uploaded to a web hosting. How can I avoid this in future, create identical environments 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.