User management with database : Authentication « HTML « PHP






User management with database

 
create table user_info (
user_id char(18),
fname char(15),
email char(35));

<?
if (! isset($userid)) :
     $id = "15";
     setcookie ("userid", $id, time()+3600);
     print "A cookie is set. Please refresh the page";
else:
     @mysql_connect("localhost", "root", "") or die("Could not connect to MySQL server!");
     @mysql_select_db("user") or die("Could not select user database!");
     $query = "SELECT * FROM user_info WHERE user_id = '$userid'";
     $result = mysql_query($query);
     $row = mysql_fetch_array($result);
     print "Hi ".$row["fname"].",<br>";
     print "Your email address is ".$row["email"];

     mysql_close();
endif;
?>
  
  








Related examples in the same category

1.Authentication Over HTTP
2.Basic authentication prompt
3.Checking the values returned from the authentication prompt
4.Get Users from users table
5.Enforcing Basic authentication
6.HTTP Authentication example
7.HTTP Authentication example forcing a new name/password
8.Hardcoding the username and password into a script
9.If user logged in
10.Only One Username and Password Is Valid
11.Usernames and Passwords Are Checked Against Data in a Database
12.Usernames and Passwords Are Checked Against Data in a File
13.Using HTTP authentication with a PHP script
14.Use database to store user name and password
15.The Username and Password Are Retrieved for Both Apache and IIS
16.Simple credentials checking: