Login takes me to the same login form and does not login when entered the correct username and password

  html, javascript, php

I made a login floating form. Whenever I try to login using the correct username and password it takes me to the login form but this time in a simple design and to another page. When I try to login from there nothing happens. Can anyone help me with this?

//logintest.php

<div class="popUpLogin">
<div class="blackBox activate"></div>
<div class="wrapper activate">
    <div class="title">
        Login Form
        <button onclick=" enableActivate() ">&times;</button>
    </div>
    <form action="includes/login.inc.php" method="post">
        <div class="field">
            <input type="text" name="name" required>
            <label>Email Address</label>
        </div>
        <div class="field">
            <input type="password" name="pwd" required>
            <label>Password</label>
        </div>
        <div class="content">
            <div class="checkbox">
                <input type="checkbox" id="remember-me">
                <label for="remember-me">Remember me</label>
            </div>
            <div class="pass-link">
                <a href="#">Forgot password?</a>
            </div>
        </div>
        <div class="field">
            <input type="submit" value="Login">
        </div>
        <div class="signup-link">
            Not a member? <a href="signup.php">Signup now</a>
        </div>
    </form>
    </div>
    <?php
    if(isset($_GET["error"])){
    if($_GET["error"] == "emptyinput"){
        echo "<p>Fill in all feilds!</p>";

    } else if($_GET["error"] == "wronglogin") {
        echo "<p>Incorrent Login Information</p>";
    } 
    }
    ?>
    </div>

//login.inc.php

<?php

if(isset($_POST["submit"])){
$username = $_POST["uid"];
$pwd = $_POST["pwd"];

require_once 'dbh.inc.php';
require_once 'functions.inc.php';

if(emptyInputLogin($username, $pwd) !== false){
    header("location: ../logintest.php?error=emptyinput");
    exit();
}

loginuser($conn, $username, $pwd);
} else {
header("location: ../logintest.php");
exit();
}

//functions.inc.php

    function loginuser($conn, $username, $pwd) {
    $uidExists = uidExists($conn, $username, $username);

    if($uidExists === false){
    header("location: ../logintest.php?error=wronglogin");
    exit();
    }

    $pwdHashed = $uidExists["usersPwd"];
    $checkPwd = password_verify($pwd, $pwdHashed);

    if ($checkPwd === false){
    header("location: ../logintest.php?error=wronglogin");
    exit();
    } else if ($checkPwd === true){
    session_start();
    $_SESSION["userid"] = $uidExists["usersID"];
    $_SESSION["useruid"] = $uidExists["usersUid"];
    header("location: ../index.php");
    exit();
    }
    }

In my header.php:

<div class="nav">
    <?php
        if(isset($_SESSION["useruid"])){
            echo "<a href='index.php' class='login' style='color: rgba(47, 128, 237, 
            1);'>Profile</a>";
        } else {
            echo "<button onclick='disableActivate()' class='login' style='color: rgba(47, 
            128, 237, 1);'>Login</button>";
            echo "<button onclick='document.location='signup.php' ' class='navSignup'> Get 
            your free card!</button>";
        }
        ?>
        </div>
        <?php
        include 'logintest.php';
        ?>
        <script>
        function disableActivate() {
        document.querySelectorAll(".wrapper")[0].classList.remove("activate");
        document.querySelectorAll(".blackBox")[0].classList.remove("activate");
        }

        function enableActivate() {
        document.querySelectorAll(".wrapper")[0].classList.add("activate");
        document.querySelectorAll(".blackBox")[0].classList.add("activate");
        }
        </script>

Source: Ask PHP

LEAVE A COMMENT