So hey there guys i am new to PHP and ran into a problem i hoped you can help me . As i was working on my login/Register system i ran into a problem.
My code is the following :
<?php
include 'core/init.php';
include 'includes/header.php';
if (isset($_POST['username'])&&isset($_POST['password'])) {
$username = $_POST['username'];
$password = $_POST['password'];
if (!empty($username)&&!empty($password)) {
$query = "SELECT `id` FROM `users` WHERE `username` = '$username' AND `password` = '$password'";
if ($query_run = mysql_query($query)) {
$query_num_rows = mysql_num_rows($query_run);
if ($query_num_rows == 0) {
echo 'Invalid username or password';
} else {
echo 'ok';
}
} else {
echo 'You must supply a valid username and a password';
}
} else {
echo 'You must supply a username and a password';
}
}
include 'includes/footer.php'
?>
When i enter the correct info it gives me the error invalid username/password so the query must be wrong ?
So please help me and Thanks for reading.