0

Trying to make a simple login page, here's the form:

    <form action="admin/login" method="post" enctype="multipart/form-data">
        <div class="input-container">
            <span class="label">Username:</span>
            <input class="login-input" type="text" name="user" required>

            <span class="label">Password:</span>
            <input class="login-input" type="password" name="pass" required>
        </div>

        <input id="login-button" type="submit" value="Log In">
    </form>

Here's the login page:

<?php
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);

    echo $_POST['user'];
?>

I just get this printed out:

Notice: Undefined index: user in /var/www/html/admin/login.php on line 6

I have no idea what is going on and i've tried everything.

user2397282
  • 3,798
  • 15
  • 48
  • 94

2 Answers2

0

Figured it out, you guys were right that it was an issue with the .htaccess file.

I just needed to add a slash after the action path:

action="admin/login/"

That's it!

user2397282
  • 3,798
  • 15
  • 48
  • 94
0

Change Action from action="admin/login" to action="admin/login.php" then submit. You are hitting login.php directly from URL that is why it is showing undefined user because user is defined as a post variable

Adnan Ali
  • 792
  • 1
  • 8
  • 21