0

I try to get data from form using $_POST but it always return error

PHP Notice:  Undefined index:

I tried everything to make it work but it is not working ??? This is my PHP Code

if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST["username"])){
    $username = $_POST['username'];
echo $username;
}
if (isset($_POST["username"])){
$password = $_POST['password'];}}

And this is the Form

<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
    <input type="text" placeholder="Username" name="username" id="username" required="required"/>
    <input type="password" name="password" placeholder="Password" id="password" required="required"/>
    <button type="submit" class="btn btn-primary btn-block btn-large" name="submit">Let me
        in.
    </button>
</form>

I used if condition to solve Undefined index problem but I still can not get my data from my Form

I using phpstorm and Ampps apache am sure from my code but I don't determine where is my problem with PHP config

I made some changes in php.ini to install XDabug but I don't remember things that I changed

Kero Fawzy
  • 690
  • 1
  • 7
  • 19
  • What is the full error message? Your second `isset` should probably be for `password`, not `username`. – chris85 Apr 28 '17 at 00:52
  • The problem is i dont get my data from form before using (if) i got two messages said PHP Notice: Undefined index: username in D:\PHP Project\ART - SHOP\Login\index.php on line 6 PHP Notice: Undefined index: password in D:\PHP Project\ART - SHOP\Login\index.php on line 9 – Kero Fawzy Apr 28 '17 at 00:55
  • i solved this problem from a long time it was just problem in apache server when i make new host for my web app it works – Kero Fawzy Jan 22 '18 at 15:36

0 Answers0