why sign in is NOT failing?!
Hi,
I am using simple sign in form with Jquery and PHP but my problem that everytime I enter anything in the email and password it accepts even if does not exist! below my jquery and PHP as well and the url is:
My Page:
- <!DOCTYPE html>
- <html manifest="cache.manifest">
- <head>
- <meta charset="UTF-8">
- <title>Welcome to Smashburger</title>
- <?php include './includes/meta.php'; ?>
- <link rel="stylesheet" href="css/signin.css">
- </head>
- <body style="background: url(images/homepage.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover;">
- <span class="button" id="toggle-login">Log in</span>
- <div id="login">
- <div id="triangle"></div>
- <div id="divLogin">
- <h1>Sign in</h1>
- <form id="login-form" name="login-form">
- <input type="email" id="txtSigninEmail" name="txtSigninEmail" placeholder="Email" />
- <input type="password" id="txtSigninPassword" name="txtSigninPassword" placeholder="Password" />
- <div style="text-align:center"><img id="imgLoading" src="images/signin_loading.gif" style="display: none;" alt="Please wait"></div>
- <input type="button" id="btnLoginNow" name="btnLoginNow" value="Sign in" /><br><br>
- <input type="button" id="btnRegister" name="btnRegister" value="Sign up Now" />
- </form>
- </div>
- <div id="divRegister" style="display: none;">
- <h1>Sign up</h1>
- <form>
- <input type="email" placeholder="First Name" />
- <input type="email" placeholder="Last Name" />
- <input type="email" placeholder="Email" />
- <input type="password" placeholder="Password" />
- <input type="button" id="btnRegisterNow" name="btnRegisterNow" value="Sign up" /><br><br>
- <input type="button" id="btnLogin" name="btnLogin" value="Sign in" />
- </form>
- </div>
- </div>
- <?php include './includes/jquery.php'; ?>
- <script src="jQueryAssets/index.js"></script>
-
- <script type="text/javascript">
- $(document).ready(function()
- {
- $('#btnRegister').click(function()
- {
- $('#divLogin').hide();
- $('#divRegister').show();
- });
-
- $('#btnLogin').click(function()
- {
- $('#divRegister').hide();
- $('#divLogin').show();
- });
-
- $('#btnLoginNow').click(function ()
- {
- $("txtSigninEmail").prop('disabled', true);
- $("txtSigninPassword").prop('disabled', true);
-
- $('#btnLoginNow').hide();
- $('#btnRegister').hide();
- $('#imgLoading').show();
-
- $.ajax({
- type: 'POST',
- url: "login.php",
- data: $('#login-form').serialize(),
- success: function()
- {
- window.location.href = 'menu';
- },
- error: function(jq,status,message)
- {
- window.location.href = '/';
-
- $("txtSigninEmail").prop('disabled', false);
- $("txtSigninPassword").prop('disabled', false);
-
- $('#imgLoading').hide();
- $('#btnLoginNow').show();
- }
-
- });
- });
- });
- </script>
- </body>
- </html>
My PHP:
- <?php
- include('includes/php_header.php');
- include($_SESSION["smashburger_absolute_path"] . '/includes/Mobile_Detect.php');
- include($_SESSION["smashburger_absolute_path"] . '/includes/password_hash.php');
- include($_SESSION["smashburger_absolute_path"] . '/includes/connect2db.php');
-
- if (isset($_POST["txtLoginName"]))
- {
- $login_email = $_POST["txtSigninEmail"];
- }
- else
- {
- exit(header("Location: ./"));
- }
-
- $login_password = $_POST['txtSigninPassword'];
-
- $password_salt = get_password_salt($login_email);
- $password_hash = hash_password($login_password, $password_salt);
-
- $mysql_query = $mysql_connection->prepare('CALL sp_signin_customer(:param_email, :param_login_password_salt, :param_login_password_hash, :param_ip_address)');
- $mysql_query->bindParam(':param_email', $login_email, PDO::PARAM_STR);
- $mysql_query->bindParam(':param_login_password_salt', $password_salt, PDO::PARAM_STR);
- $mysql_query->bindParam(':param_login_password_hash', $password_hash, PDO::PARAM_STR);
- $mysql_query->bindParam(':param_ip_address', $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR);
-
- $mysql_query->execute();
-
- if ($mysql_query->rowCount() <= 0)
- { exit(header("Location: index.php")); }
-
- while($mysql_row = $mysql_query->fetch())
- {
- $_SESSION["id"] = session_id();
- $_SESSION["timestamp"] = time();
- $_SESSION["loggedOn"] = true;
- $_SESSION["customer_id"] = $mysql_row["customer_id"];
- }
- ?>
Thanks,
Jassim Rahma