I am trying to make a simple php and sql login form, but it is not working
Can anyone help me to fix my code?
<form method="post" action="form.php">
Username <input type="text" name="username"><br>
Password <input type="password" name="password">
<br>
<input type="submit" name="submit" value="submit">
</form>
<?php
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$con = mysql_connect("localhost", "root", "");
mysql_select_db($con, "formcolumn");
$sql = mysql_query("select * from data1_table where username='$username' and password='$password' ");
$row = mysql_fetch_array($sql);
$uname = $row['username'];
$pass = $row['password'];
if ($username == $uname && $password == $pass) {
header("Location: main.php");
} else {
echo "invalid username and password ";
}
}
?>