I know this question have been asked before and I've searched it but couldn't get to solve my problem. whenever I run this code, I get "invalid login" message. username and password is saved in mysql database. Below is my code.
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$db = "mydb";
$dbconnect= mysqli_connect($dbhost, $dbuser, $dbpass, $db);
mysqli_select_db($dbconnect,$db) or die("could not connect to database");
if (isset($_POST['username']) && isset($_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];
$username = stripslashes($username);
$password = stripslashes($password);
$query = "SELECT * from users WHERE username = '$username' AND password = '$password' LIMIT 1";
$result = mysqli_query($query);
$count = mysqli_num_rows($result);
if($count==1){
echo "Login successufull!!!";
exit();
}else{
echo "Invalid login";
exit();
}
}
?>
<!Doctype html>
<html>
<head>
<link href='style.css' type='text/css' rel='stylesheet'>
</head>
<body>
<form action = 'main.php' method="post" enctype='multipart/data-form'>
<h1>User login information</h1>
<p>Username:<input type= 'text' name='username'></p>
<p>Password:<input type = 'password' name = 'password'></p>
<p><input type = 'submit' name = 'submit' value='Submit'></p>
</form>
</body>
</html>
$result = mysqli_query($query);- what's missing? deviated from your other question's method stackoverflow.com/q/33593455stop programming a pick up another careerkinda harsh ? we don't know that which purpose he is using this. You can suggest something but thats not mean the harsh wayecho "Invalid login";get the real error.