dongyan2445 2019-08-15 14:24
浏览 35

如何制作,以便我可以使用电子邮件和用户名登录?

I cannot make it so i can login with both, when i try, it either doesnt register both email and username, or password doesnt work.

if(isset($_POST['mit'])){
    $username = $_POST['user'];
    $password = $_POST['word']; 
    $sql = "SELECT * FROM users WHERE user='$username' AND password='$password'";
    $result = mysqli_query($db, $sql);
    if (mysqli_num_rows($result) == 1){
        $_SESSION['user'] = $username;

        header("location: index.php");
    }
    else{
        echo "<p style=\"color:white\"> Login failed</p>";
    }
}

Page

<form action="log.php" method="post">
    <h3>Username/Email:</h3>
    <input type="text" name="user" placeholder="Username">
    <h3>Password:</h3>
    <input type="Password" name="word" placeholder="Password">  
    <br>
    <input type="submit" name="mit">
    </form>
  • 写回答

0条回答 默认 最新

    报告相同问题?