php - HTML custom login -
so have website making, , keep running php files html files, php 1 not work correctly.
html:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>authentication</title> </head> <body> <form method="post" action="php/password.php" style="text-align:center"> enter authentication code: <input type = "password" name = "password" value = ""> <input type = "submit" value = "submit"> </form> </body> </html> php:
<?php if (isset($_post['submit'])) { $pass = $_post['password'] if ($pass == "111") { header("location: ../html/index1.html"); }else { {?> <form method="post" action="../php/password.php" style="text-align:center"> enter authentication code: <input type = "password" name = "password" value = ""> <input type = "submit" value = "submit"> <br /> <font color = "red">incorrect password!</font> </form> <?} } } ?> the php supposed typed, , if equal "111" redirects different part of website. if not, tells password incorrect, , runs else. but, no matter type, considers password "wrong" , "else" part of code. help?
picture of directory: https://gyazo.com/7d49b063cd5dfaf6405e3704b3f3fa96
note: not care changing more secure hobby working on.
like others said, submit not value sending, instead of try this
if (!empty($_post)) then this..
<?php if (!empty($_post)){ $pass = $_post['password'] if ($pass == "111"){ header("location: ../html/index1.html"); }else{ {?> <form method="post" action="../php/password.php" style="text-align:center"> enter authentication code: <input type = "password" name = "password" value = ""> <input type = "submit" value = "submit"> <br /> <font color = "red">incorrect password!</font> </form> <?} } } ?> i change html php file , wont need duplicate form code.. send parameter or error , able read , display @ screen.
rename login login.php , this
<?php if (!empty($_post)){ $pass = $_post['password'] if ($pass == "111"){ //wherever want go after login }else{ $password = false; } } ?> <form method="post" action="#" style="text-align:center"> enter authentication code: <input type = "password" name = "password" value = ""> <input type = "submit" value = "submit"> <br /> <?php if(isset($password) && ($password != true){ ?> <font color = "red">incorrect password!</font> <?php } ?> </form>
Comments
Post a Comment