-2

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!

B.Daddy
  • 9
  • 1
  • 7

2 Answers2

-1

For Submit button Use input instead of a tag. For example:

 <form action="demo_form.php">
   Username: <input type="text" name="usrname"><br>
   <input type="submit" value="Submit">
 </form> 
-1

i think you should replace this two line in login.php.

$emailbox         = $_POST ["loginemailbox"];
$loginpasswordbox = $_POST ["loginpasswordbox"];

with this.

$emailbox         = $_POST["loginemailbox"];
$loginpasswordbox = $_POST["loginpasswordbox"];

remove blank space.

Divyesh Jesadiya
  • 1,105
  • 4
  • 30
  • 68