Jump to content

Recommended Posts

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

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()

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());

Edited by rafal
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.