rafal Posted October 29, 2014 Share Posted October 29, 2014 Hallo everybody, the user is in the table, but i get error (user not found!). thank you very much for your help Rafal <!DOCTYPE html> <html> <head> <title>index</title> <meta http-EQUIV="CONTENT-LANGUAGE" content="en"> <?php SESSION_START(); include("abc.php"); $link2 = mysqli_connect("$hoster", "$nameuser", "$password", "$basedata") or die ("connection error" . mysqli_error($link2)); $email = $_POST["inp_email"]; $pwd = $_POST["inp_pwd"]; if($email && $pwd) { $chkuser = mysqli_query("SELECT email FROM $table2 WHERE email = '$email' "); $chkuserare = mysqli_num_rows($chkuser); if ($chkuserare !=0) { $chkpwd = mysqli_query("SELECT pwd FROM $table2 WHERE email = '$email'"); $pwddb = mysqli_fetch_assoc($chkpwd); if (md5($pwd) != $pwddb["pwd"]) { echo "Password is wrong!"; } else { $_SESSION['username'] = $email; header ('Location:list.php'); } } else { echo "user not found!"; } } else { echo "enter your Email and Password!"; } mysqli_close($link2); ?> </head> <body style="font-family: arial;margin: 10; padding: 0" bgcolor="silver"> <font color="black"> <br> <form action="index.php" method="post"> <b>Login</b><br><br> <table width="100%"> <tr><td> Email:<br><input type="text" name="inp_email" style="width:98%; padding: 4px;"><br> Password:<br><input type="password" name="inp_pwd" style="width:98%; padding: 4px;"><br> <br> <input type="submit" name="submit" value="Login" style="width:100%; padding: 4px;"> </td></tr> </table> </form> </font> </body> </html> Link to comment https://forums.phpfreaks.com/topic/292130-user-login-user-not-found/ Share on other sites More sharing options...
mac_gyver Posted October 29, 2014 Share Posted October 29, 2014 your mysqli_query() statements are incorrect. they require the database connection link variable as a parameter. you need to have php's error_reporting set to E_ALL and display_errors set to ON so that php will help you. your usage of mysqli_query() would be throwing a php error. you also need to read the php.net documentation for the php functions you are using. converting your code from mysql_ to mysqli_ statements requires that you know the correct usage of those functions. also, for your mysqli_connect() error handling, you cannot use mysqli_error($link2) because there is no database connection in $link2 and the msyqli_error statement itself will throw a php error. you must use mysqli_connect_error() to get the connection error. there are examples of this in the php.net documentation for mysqli_connect() Link to comment https://forums.phpfreaks.com/topic/292130-user-login-user-not-found/#findComment-1495109 Share on other sites More sharing options...
rafal Posted October 29, 2014 Author Share Posted October 29, 2014 Hello mac_gyver, thank you very much for your help. i did not understood your point1 about mysqli_query() statements. i did not understood your point2 about php's error_reporting set. point3, do you mean like the following is correct? or die ("connection error" . mysqli_connect_error()); Link to comment https://forums.phpfreaks.com/topic/292130-user-login-user-not-found/#findComment-1495184 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.