I recently tried to create a login form for my social networking website. It works but not the way I want it to. All I have to put in is a username and I'm logged in. I want to it to be username and password because of security. I tried before to fix this problem but nothing works. So I want to see if I can get help on here.
signin.php:
<html>
<head>
<title>Interpage</title>
</head>
<body bgcolor="#E6E6FA">
<h1><center>Login</center></h1>
<form action="process.php" method="post">
<p align="center">
<input type="text" name="username" size="35" id="Username" placeholder="Username" /></p>
<br></br>
<p align="center">
<input type="password" name="password" size="35" id="Password" placeholder="Password" /></p>
<center>
<input type="submit" name="login" value="Log In"/></center>
<h3 style="font-size: 20px"><a href="register.php">Go Back To Home Screen</a></h3>
</form>
</body>
</html>
process.php:
<?php
include("db.php");
if ( isset( $_POST['login'] ) ) {
$username = $_POST['username'];
$pw = $_POST['StorePassword'];
$query = mysqli_query($conn, "SELECT * FROM users WHERE username='".$username."'");
if ( mysqli_num_rows($query) > 0 ) {
while ( $row = mysqli_fetch_assoc( $query ) ) {
if ( $row['StorePassword'] == $StorePassword ) {
header("Location: home.php");
} else {
echo "Wrong password";
}
}
} else {
echo "User not found <br />";
}
if ( !isset($_POST['username'], $_POST['StorePassword']) ) {
die ('You must enter a username and password! <a href= signin.php>Try again</a> ');
} else {
}
}
?>