Login system PHP
Go to solution
Solved by leonfagan71,
1 minute ago, Bartb56 said:I'm trying to make a login system in PHP but it keeps saying my login is wrong please help.
<?php session_start(); include('dbconn.php'); $username= $_POST['username']; $password= $_POST['password']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $result = mysqli_query($con, "SELECT username, password FROM users WHERE username = '".$username."' AND password = '".$password."'"); $count =mysql_num_rows($result); if ($count==1){ header("Location: index.html"); } else { echo"Nope"; } ?>
You're using mysql_real_escape_string, change this to:
$username = mysqli_real_escape_string($con, $username);
for example.
also, mysql_num_rows needs to be mysqli_num_rows
If you still have issues, PM me.
Regards,
Leon.
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