创建登录页面PhP SQL

时间:2018-03-22 10:55:14

标签: php sql login

我真的很新,所以我赞成如果你能保持答案真的很简单和基本所以我能理解。 所以我试图建立一个简单的登录平台,但它不起作用.. 我认为我对sql代码有一些问题,因为$ rows标记并不算作适合包含在数据库中的用户的一行。 thx in advanced。

<?php

session_start(); ?>

include "config.php";
$wrong_dt="";
if(isset($_POST['email']) && $_POST['email']!="" && isset($_POST['password']) && $_POST['password']!=""){
             $pw = mysqli_prepare($conn , "SELECT `email` FROM `Users` WHERE `email` = ? AND `password` = ? LIMIT 1");
            if($pw){
                 echo "good";
                 echo $_POST['email'];
                 echo $_POST['password'];

               mysqli_stmt_bind_param($pw, "ss" , $_POST['email'] , $_POST['Password']);
               mysqli_stmt_execute($pw);
                $result= mysqli_stmt_get_result($pw);
            echo mysqli_num_rows($result);
               if(mysqli_num_rows($result) > `0){

                   $_SESSION['email']=$_POST['email'];
                   header("Location:Find.php");
               }
               else{
                   $wrong_dt="wrong details";
               }
            }
}

?>

             MusicRun                           

</head>
<header>
    <h1> MusicRun </h1>
    <h5>Same Hobby.Same Music.</h5>
    <p>MusicRun is a platform for people who likes running in a group with other people who likes the same music as they do</p>
</header>

<body background= "http://www.spyderonlines.com/images/nike_sports_athletics_run_running_81188.jpg">
    <main>

        <form method="post" action="login.php">
          <div class="form-group">
            <label for="exampleInputEmail1">Email address</label>
            <input type="email" class="form-control" name="email" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
            <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
          </div>
          <div class="form-group">
            <label for="exampleInputPassword1">Password</label>
            <input type="password" class="form-control" name="password" id="exampleInputPassword1" placeholder="Password">
            <button type="submit" class="btn btn-primary" id="loginBtn">Login</button>
          </div>
          <p><?php echo $wrong_dt ?></p>
          <div class="newAccount">
            <p>Not a User yet?</p>
            <button type="button" class="btn btn-primary" id="login_button" onclick="window.location.href='http://matanhm.myweb.jce.ac.il/Final%20Project/register.php'">Sign up</button>
          </div>
        </form>


    </main>


    <footer>

    </footer>

</body>

0 个答案:

没有答案