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