I am trying to make a login form with php and mysql and failed from past 3 days.
I have basically php form and on the same page the scripting for logging the user into the website.
form.php
<form id="superAdminForm" method="post" action="">
<input type="email" name="email" required class="txtInput" placeholder="Email..." autocomplete="off"/> <br />
<input type="password" name="password" required class="txtInput" placeholder="Password..."/> <br />
<input type="submit" name="submit" value="Enter" id="submit" />
</form>
php code for form.php
<?php
require("../php_includes/db-connect.php");
if (isset($_POST["submit"])) {
$email = $_POST["email"];
$password = $_POST["password"];
$sql = "SELECT * FROM users WHERE email='$email' AND password='$password' LIMIT 1";
$query = mysqli_query($con, $sql);
$row = mysqli_fetch_array($query);
if ($row['email'] == 1) {
header("Location: admin-index.php");
}
}
mysqli_close($con);
?>
The problem is that the login is not getting successfull. I don't know the reason behind it. So please help me in this. Also guide me where I am making mistakes.
I am new in PHP and am trying my best to cope up with my knowledge.
