Jump to content

tarunrathore

New Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About tarunrathore

  • Rank
    Newbie
  1. I have a simple log in form. By debugging I found that isset post submit function is not responding. It remains on the same page after submitting form. I have googled all the possible solutions to this problem but none worked. Any help is greatly appreciated. The form is in multiplelogin.php file and the code is in multi.php file. After login redirection is to teachers.php file. <?php session_start(); $conn = mysqli_connect("localhost", "root", "", "signup"); if(isset($_SESSION['username'])) { header('location: teachers.php'); exit(); } ?> <!DOCTYPE html> <head> <link rel="stylesheet" type="text/css" href="bootstrap.css"> <title> Teachers Students Login </title> </head> <body class="bg-secondary"> <div class="container"> <div class="row justify-content-center"> <div class="col-log-5 bg-light mt-5 px-0"> <h3 class="text-center text-light bg-primary py-3 px-5"> Log In </h3> <?php if(isset($_GET['error'])) { if ($_GET['error'] == 'invalidemail') { echo "<p class='alert'> Invalid Email Id! </p>"; } else if ($_GET['error'] == 'wrongpassword') { echo "<p class='alert'> Incorrect Password! </p>"; } } ?> <form action="multi.php" action="post" class="py-4 px-5" id="form"> <div class="form-group px-5"> <input type="email" name="email" class="form-control form-control-lg" placeholder="Email" required> </div> <div class="form-group px-5"> <input type="password" name="password" class="form-control form-control-lg" placeholder="Password" required> </div> <div class="form-group px-5"> <input type="submit" name="submit" value="Submit" class="btn btn-primary btn-block"> </div> </form> </div> </div> </div> </body> </html> <?php ini_set( 'display_errors', 1 ); error_reporting( E_ALL ); if (isset($_POST['submit'])) { $conn = mysqli_connect("localhost", "root", "", "signup"); $email = $_POST['email']; $password = $_POST['password']; $sql = "SELECT * FROM teachersRegist WHERE email=?"; $stmt = mysqli_stmt_init($conn); if (!mysqli_stmt_prepare($stmt, $sql)) { header("Location: multilogin.php?error=sqlerror"); exit(); } else { mysqli_stmt_bind_param($stmt, "s", $email); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); if ($row = mysqli_fetch_assoc($result)) { $pwdCheck = password_verify($password, $row['password']); if ($pwdCheck == false) { header("Location: multilogin.php?error=wrongpassword"); exit(); } else if ($pwdCheck == true) { session_start(); $_SESSION['username'] = $row['username']; $_SESSION['email'] = $row['email']; header("Location: teachers.php?login=success"); exit (); } else { header("Location: multilogin.php?error=wrongpassword"); exit(); } } else { header("Location: multilogin.php?error=invalidemail"); exit(); } } } else { header("Location: multilogin.php"); exit(); } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.