html - Login php code not doing anything? -
this question has answer here:
i'm using simple text document holds password in site directory public_html/users/matt/password.txt issue i'm having code when submit button pressed nothing seems happening. i'm sure it's silly mistake, have ideas here?
<?php ob_clean();session_start(); if (isset($_get['logout'])){ session_destroy(); } $username = $_post['username']; $enteredpassword = $_post['password']; if (isset($_post['submit'])){ if (is_dir("users/".$username) === true){ $myfile=fopen("users/".$username."/password.txt","r") or exit("can't open file!"); $correctpassword = fgets($myfile); fclose($myfile); echo 'username found.'; if ($correctpassword == $enteredpassword){ echo 'login successful.'; } else { echo 'password incorrect.'; } } else { echo 'username not found.'; } echo 'checking if username found...'; } ?> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>project archive - login</title> <link href="css/master.css" rel="stylesheet" type="text/css"> <script src="javascript/respond.min.js"></script> </head> <body> <div id="containerdiv"> <div id="titlediv"> <font size="20pt"> <p align="center">project archive</p> </font> <div id="loginboxdiv"> <form method="post" action="index.php"> <div id="username"> <p>username:</p> <input type="text" name="username" size="12"> </div> <div id="password"> <p>password:</p> <input type="password" name="password" size="12"> </div> <div id="btnlogin"> <input id="button" type="submit" value="login"> </div> </form> </div> </div> </div> </body> </html>
add name submit button
<div id="btnlogin"> <input id="button" name='submit' type="submit" value="login"> </div>
Comments
Post a Comment