Getting PHP Errors, can anyone help?
Go to solution
Solved by mattonfire,
40 minutes ago, homeap5 said:Third error means that you're using new version if php without that function enabled.
Try to use mysqli_real_escape_string this instead
Changed my usage to mysqli instead of mysqli seems to be working better.
34 minutes ago, vorticalbox said:
$username = $_POST['username'];$password = $_POST['password'];
You are looking for username and password in the POST but their name in the form is user and pass
$username = $_POST['user'];$password = $_POST['pass'];
This worked. Thank you.
<?php $con = mysqli_connect("localhost","root","",""); $username = $_POST['user']; $password = $_POST['pass']; $username = stripcslashes($username); $password = stripcslashes($password); $username = mysqli_real_escape_string($con, $username); $password = mysqli_real_escape_string($con, $password); $result = mysqli_query($con,"SELECT * FROM users WHERE username = '$username' and password = '$password'") or die("Failed to Query Database. ".mysqli_error($con)); $row = mysqli_fetch_array($result); if ($row['username'] == $username && $row['password'] == $password ){ echo "Login Successful. Welcome, ".$row['username']; } else { echo "Login Failed. Please try again."; } ?>
*EDIT*
Found it. You both get rep.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now