How to login properly using HTML and php? -


so, i'm creating simple file share site takes in user name login. when have correct user name, program thinks it's wrong below code:

<form method ="post">     <p>          <label for="user">user id: </label><input type="text" name="userid" id="user" />      </p>     <p>          <input type="submit" name = "login" value="log in" />          <input type ="reset"/>     </p> </form> 

php part

<?php $users = file('users.txt'); if (isset($_post['login'])) {     echo $_post['userid'].'<br>'; foreach ($users $user) {     if ($_post['userid']==$user){         header("location: fileshareloginredirect.php");         exit;     } } echo "wrong id".'<br>'; ?> 

what might doing wrong? seems should work.

the submit button value not sent along post.

you should not use submit button try pass form values.

<form method ="post">         <p>              <label for="user">user id: </label><input type="text" name="userid" id="user" />          </p>         <p>              <input type="submit" value="log in" />              <input type ="reset"/>         </p>     </form> 

php part

<?php $users = file('users.txt'); if (isset($_post['userid'])) {     echo $_post['userid'].'<br>'; foreach ($users $user) {     if ($_post['userid']==$user){         header("location: fileshareloginredirect.php");         exit;     } } echo "wrong id".'<br>'; ?> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -