Basic php Login form with defined Name and Password -


i beginner in php programming . have been trying create basic login form fixed username , password in if loop , first time run program warning if-else loop cant figure out runs perfectly. want show error below submit when enter wrong password or username . cant figure out how .

<html> <head> <style> #login {      position:absolute;     top: 30%;     bottom: 30%;     left:30%;     right:30%;     margin: 0px auto;     width:auto;     height:600px; }  </style> </head> <body> <?php echo"<center>"; echo"<div id=\"login\">";  echo"<form method=\"post\">"; echo"<b>username</b>  <input type =\"text\" name=\"username\">"; echo"<br/><br/>"; echo"<b>password</b>&nbsp;<input type =\"password\" name=\"password\">"; echo"<br/><br/>"; echo"<input type=\"submit\" value=\"submit\">";  echo"</div>"; echo"</center>";  if($_post['username'] =="user" && $_post['password']=="user")   {    header("location: contact.php");     }  else   {   // want display error when clicking submit    }    ?>    </body>    </html> 

the first time run script, $_post['username'] (and password) isn't defined.

what have check if it's defined this:

if(isset($_post['username']) && $_post['username'] == "user" && isset($_post['password']) &&  $_post['password']=="user") 

here's link isset function

also, check on top of page. because you'r sending content, redirect won't work.

header() must called before actual output sent, either normal html tags, blank lines in file, or php


Comments

Popular posts from this blog

Java 8 + Maven Javadoc plugin: Error fetching URL -

css - SVG using textPath a symbol not rendering in Firefox -

order - Notification for user in user account opencart -