I'm building a login system with PHP and I can't figure out why my code isn't working. When I submit the login form, the page just refreshes and nothing happens. Can someone help me find the error in my code?
<?php
session_start();
if(isset($_POST['loginbtn'])){
require_once 'index.php';
require_once 'Database_conx.php';
$emailbox = $_POST ["loginemailbox"];
$loginpasswordbox = $_POST ["loginpasswordbox"];
$loginpasswordbox = md5($loginpasswordbox);
$result = mysqli_query($conn, 'SELECT * FROM Registration where Email = "'.$emailbox.'" and User_Password= "'.$loginpasswordbox.'" ');
if(mysqli_num_rows($result) == 1) {
$_SESSION['loginemailbox'] = $emailbox;
header('Location:home.php');
}
}
?>
And here's my HTML code, which is located in my index.php file:
<div id="header_top_password">
<input type="password" class="form-control" placeholder="Enter Password" name="loginpasswordbox" style="border :0px">
</div>
<div id="loginbutton">
<button type="submit" name="loginbtn" class="btn btn-danger pull-right">Login</button>
</div>
<div id="forget_Password">
<button type="button" class="btn btn-link">Forget your Password?</button>
</div>
Can someone tell me what I'm doing wrong? Thanks in advance for your help!