The submit button is not working in login page

PHP CODE

<?php define('DB_HOST', 'localhost'); define('DB_NAME', 'hotel'); define('DB_USER','root'); define('DB_PASSWORD',''); $con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error()); $db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error()); $email = $_POST['email']; $password = $_POST['pass']; function SignIn() { session_start(); if(!empty($_POST['email'])) { $query = mysql_query("SELECT * FROM signup where email = '$_POST[email]' AND password = '$_POST[pass]'") or die(mysql_error()); $row = mysql_fetch_array($query) or die(mysql_error()); if(!empty($row['email']) AND !empty($row['pass'])) { $_SESSION['email'] = $row['pass']; header("location : booking.php "); } else { echo "SORRY... YOU ENTERED WRONG ID AND PASSWORD... PLEASE RETRY..."; } } } if(isset($_POST['submit'])) { SignIn(); } ?>

HTML CODE

<title>MM</title>    

<link rel="stylesheet" type="text/css" href="css/style.css"> 

<script>

function thankyou()

{

    if(email=='')

    {

        alert('Please enter your email');

    }

    else

    {        

        window.location.href ="booking.html" ;                                   

        alert('Login Successful');



    }

} 
<h2>Login Page</h2><br> 

<form action="login.php" method="POST">   

<div class="login">       

    <label><b>Email<br>

    </b>    

    </label>    

    <input type="text" name="email" id="email" placeholder="Email">    

    <br><br>    

    <label><b>Password     

    </b>    

    </label>    

    <input type="Password" name="pass" id="pass" placeholder="Password">    

    <br><br>    

    <input type="button" name="submit" id="submit" value="Log In" onclick=thankyou() >

    <br><br>    

    <input type="checkbox" id="check">    

    <span>Remember me</span>    

    <br><br>    

     <p>Contact Us.(If forgot password)</p>    

    New here?----------------->

    <a href="signup.html">Click here</a>

</form>     

You are using dangerous, obsolete code that has been removed from Php. You need to use PDO with Prepared Statements. This code is not fixable.

This will get you going.
https://phpdelusions.net/pdo

@benanamen yes i made a new code using pdo and it did the work . Thanks alot

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service