Page 1 of 1

login form

Posted: Wed Nov 26, 2003 6:17 am
by kujtim
halo
I want to create a simply login form withaut a db, this login form is going to be used from just one user

some thing like this:
if the user name and password is corect to be able to get in to the page
this page is going to be able to see onli one user the user who got a password....

please help ......

Posted: Wed Nov 26, 2003 7:30 am
by Weirdan

Code: Select all

<?php
  $login="someone";
  $pass="password";
  if((@$_POST["login"]==$login)&&(@$_POST["pass"]==$pass)){
?>
 protected page goes here
<?php
  }else{
?>
  <form action="<?=$_SERVER['PHP_SELF'];?>" method="POST">
   <input type=text name="login"/>
   <input type=password name="pass"/>
   <input type=submit value="Log in"/>
  </form>
<?php
 }
?>
Something like this...

Posted: Wed Nov 26, 2003 8:43 am
by d3ad1ysp0rk
if((@$_POST["login"]==$login)&&(@$_POST["pass"]==$pass)){

what are the @ symbols used for weirdan?

Posted: Wed Nov 26, 2003 9:05 am
by twigletmac
The @ symbols are to prevent it showing a warning when the $_POST variables aren't set - @ suppresses errors. Be wary in using @ whilst developing as it can mean you miss useful errors and warnings when debugging.

Mac