login form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kujtim
Forum Commoner
Posts: 35
Joined: Sat Oct 25, 2003 4:00 am
Location: kosovo
Contact:

login form

Post 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 ......
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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...
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

if((@$_POST["login"]==$login)&&(@$_POST["pass"]==$pass)){

what are the @ symbols used for weirdan?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply