-1

i am trying to build a login system with php , can anyone point me to my 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 the following html code is found on my index.php

<form id="login" action="login.php" method="post">
  <div id ="header_top_login">
   <input type="text" class ="form-control" placeholder = "Enter Email"    name = "loginemailbox" style="border :0px;">
                 </div>

     <div id = "header_top_password">
       <input type="password" class = "form-control" placeholder = "Enter Password" name = "loginpasswordbox" style = "border :0px">
                </div>

                <div id = "loginbutton">
                    <a href="login.php" type=" submit" name="loginbtn" class="btn btn-danger pull-right"  > Login</a>
                </div>

                <div id="forget_Password" >
                    <button type="button" class="btn btn-link">Forget your Password ?</button>
                </div>   
          </form>

can anyone tell me what am doing wrong.

B.Daddy
  • 21
  • 1
  • 6

2 Answers2

0

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> 
0

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,287
  • 4
  • 30
  • 58