Foser Posted July 6, 2007 Share Posted July 6, 2007 <?php //starting SESSION session_start(); //Lazy Login if ($_SESSION['LOGGEDIN'] == TRUE){ header("Location: main/index.php");} //SQL Configuration file require("config.php"); //when pressed submit execute the FOLOWING if (isset($_POST['submit'])){ // USER TYPED INFORMATION $user = mysql_real_escape_string($_POST['username']); $password = sha1(md5($_POST['password'])); // Searching DB for username and password Match $result = mysql_query("SELECT * FROM user_info WHERE username = '$user' and password = '$password'") or die(mysql_error()); if (mysql_num_rows($result) > 0 or die(mysql_error())){ // SETTING UP SESSIONS $_SESSION['LOGGEDIN'] = TRUE; $_SESSION['UNAME'] = $user; //Go To Member Control Panel if ($_SESSION['LOGGEDIN'] = TRUE){ header("Location: main/index.php"); exit; }} // IF EVERYTHING ELSE IS FALSE EXECUTE THIS: else { echo "You have not entered the correct data. You may try again.";}} ?> when i enter the wrong data in either or both fields. I get a blank page. Link to comment https://forums.phpfreaks.com/topic/58708-both-fields-false-but-else-statement-not-executing/ Share on other sites More sharing options...
per1os Posted July 6, 2007 Share Posted July 6, 2007 Post the login form. Link to comment https://forums.phpfreaks.com/topic/58708-both-fields-false-but-else-statement-not-executing/#findComment-291189 Share on other sites More sharing options...
Foser Posted July 6, 2007 Author Share Posted July 6, 2007 <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label>Username: <input type="text" name="username" id="username"> </label> <br> Password: <label> <input type="password" name="password" id="password"> </label> <br> <label> <input type="submit" name="submit" id="submit" value="submit"> </label> </form> its in the same file. Link to comment https://forums.phpfreaks.com/topic/58708-both-fields-false-but-else-statement-not-executing/#findComment-291205 Share on other sites More sharing options...
per1os Posted July 6, 2007 Share Posted July 6, 2007 if (mysql_num_rows($result) > 0 or die(mysql_error())){ Thats why you are getting a blank page, there is no error on the mysql part and since you entered the data wrong it goes to the or portion. <?php //starting SESSION session_start(); //Lazy Login if ($_SESSION['LOGGEDIN'] == TRUE){ header("Location: main/index.php");} //SQL Configuration file require("config.php"); //when pressed submit execute the FOLOWING if (isset($_POST['submit'])){ // USER TYPED INFORMATION $user = mysql_real_escape_string($_POST['username']); $password = sha1(md5($_POST['password'])); // Searching DB for username and password Match $result = mysql_query("SELECT * FROM user_info WHERE username = '$user' and password = '$password'") or die(mysql_error()); if (mysql_num_rows($result) > 0){ // SETTING UP SESSIONS $_SESSION['LOGGEDIN'] = TRUE; $_SESSION['UNAME'] = $user; //Go To Member Control Panel if ($_SESSION['LOGGEDIN'] = TRUE){ header("Location: main/index.php"); exit; }} // IF EVERYTHING ELSE IS FALSE EXECUTE THIS: else { echo "You have not entered the correct data. You may try again.";}} ?> The above should hit the else. Link to comment https://forums.phpfreaks.com/topic/58708-both-fields-false-but-else-statement-not-executing/#findComment-291212 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.