0

I'm trying to make login form method=POST but if click button submit on the next page php inform me:

Notice: Undefined index: username in C:\xampp\htdocs\Kurs\odbierz.php on line 99

Notice: Undefined index: haslo in C:\xampp\htdocs\Kurs\odbierz.php on line 100

login page(post.php):

<body>
            <div id="form">
              <form name="loginform" method="POST" action="odbierz.php" enctype="multipart/form-data">
                <div id="odbierz">
                  <div id="login">
                    Login: <input id="log" type="text" name="username" value="" maxlength="20" size="30" required />
                    <div id="pass">
                      <br />                      
                      Password: <input id="pass" type="password" name="haslo" value="" maxlength="20" size="30" required />
                    </div>
                    <div id="input">
                      <input type="submit" name="submit" value="Zaloguj Się" />
                    </div>
                  </div>
                </div>
              </form>
            </div>
          </body>

action page(odbierz.php):

<?php
            echo $pagname;
            if($_SERVER["REQUEST_METHOD"] == "POST")
              if(isset($_POST['username']) && isset($_POST['haslo']))
                echo "Hello ".$_POST["username"]." ".$_POST["haslo"];
              else
                echo "Coś poszło nie tak<br />";
            else
              echo "Coś poszło nie tak<br />";
            ?>

Thanks any helping Person.

  • `enctype="multipart/form-data"` - what should that be used for? A common `POST` form does not need that – Nico Haase Sep 26 '22 at 17:42
  • 1
    Does this answer your question? [What does enctype='multipart/form-data' mean?](https://stackoverflow.com/questions/4526273/what-does-enctype-multipart-form-data-mean) – Nico Haase Sep 26 '22 at 17:43
  • I asked about $_POST - this value isn't set after submit form. enctype="multipart/form-data - that's no problem. Please focused on value $_POST. Thanks – Grzegorz Gielas Sep 26 '22 at 20:58
  • Did you try to dump `$_POST` to check what's in there? – Nico Haase Sep 27 '22 at 06:41
  • Yes I try but $_POST is empty and I don't know why – Grzegorz Gielas Sep 27 '22 at 14:55
  • You should inspect the request that is happening in your browser's developer console – Nico Haase Sep 27 '22 at 14:59
  • I found problem -> .htaccess: RewriteEngine on RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC] RewriteRule ^ /%1 [NC,L,R] RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^ %{REQUEST_URI}.php [NC,L] When I delete file the form was work fine. However I will be study how the file .htaccess should look like because I want to look www url nice for user. Thanks – Grzegorz Gielas Sep 27 '22 at 21:05

0 Answers0