@camperextraordinaire
@PriyaMe
@Steffan153
Pls help, the below code is giving me error:
<?php
// Get values passe from form in login.php file
$username = $_POST['user'] = 'testuser';
$password = $_POST['pass'] = "' or ''='";
// to prevent mysql injection
$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysqli_real_escape_string($connect, $_POST['user']);
$password = mysqli_real_escape_string($connect, $_POST['pass']);
$pass1 = mysqli_real_escape_string($connect, $_POST['pass1']);
$email = mysqli_real_escape_string($connect, $_POST['email']);
// connect to the server and select database
mysqli_connect("localhost", "root", "");
mysqli_select_db("login");
// Query the database for user
$result = mysql_query("select * from users where username = '$username' and password = '$password'")
or die("Failed to query database ".mysql_error());
$row = mysql_fetch_array($result);
if ($row['username'] == $username && $row['password'] == $password){
echo "Login success!!! Welcome ".$row['username'];
} else {
echo "Failed to login!";
}
?>