vendredi 24 juin 2016

Button goes to another page instead of going to PHP server side

I have a problem when i press "Sign In" Button, it immediately goes to index.html page instead of going to php server side. Anyone can help me identify the problem? Thanks

<?php
    session_start();

    include "connect.php";

    if (isset($_SESSION['user']) != "") {
        header("Location: testhomepage.php");
    }

    if (isset($_POST['submit'])) {
        $Username = stripcslashes($_POST['TPxxxx']);
        $Username = strip_tags($Username);
        $Username = mysqli_real_escape_string($con, $Username);

        $Password = stripcslashes($_POST['pass']);
        $Password = strip_tags($Password);
        $Password = mysqli_real_escape_string($con, $Password);

        $checkuser = "Select * from student Where StudentTP = '$Username'";
        $result2 = mysqli_query($con, $checkuser);

        $row = mysqli_fetch_array($result2);

        if ($row['StudentPassword'] == md5($Password)) {
            $_SESSION['user'] = $row['StudentName'];
            header("Location: home.php");
        } else {
            echo "<script type='text/javascript'> alert('Wrong username or password');
          location='login.php';
          </script>";
        }

        mysqli_close($con);

    }

    ?>
      </head>

      <body>

        <link href='http://fonts.googleapis.com/css?family=Open+Sans:700,600' rel='stylesheet' type='text/css'>

    <form method="post" action="index.html">
    <div class="box">
    <h1>Login to iSpace</h1>

    <input type="text" name="TPxxxx" value="TPxxxx" onFocus="field_focus(this, 'TPxxxx');" onblur="field_blur(this, 'TPxxxx');" class="email" />

    <input type="password" name="pass" value="TPxxxx" onFocus="field_focus(this, 'TPxxxx');" onblur="field_blur(this, 'TPxxxx');" class="email" />

    <button class="btn" type="submit" id="submit">Sign In</button> <!-- End Btn -->

    </div> <!-- End Box -->

    </form>

So first what I want from this code is i want to check Username and Password by using PHP and if the validation is complete, it will go to home.php while if the validation is wrong, user will go back to login page again

Aucun commentaire:

Enregistrer un commentaire