write a php code for adminiisrator Note that only the admini
write a php code for adminiisrator. Note that only the administrator should be allowed to view the admin.php page, whereas unregistered users should not be able to view it.
Solution
Following code directs admin type user to admin.php. $query=\"SELECT * FROM account WHERE username=\'$user\' AND password=\'$pass\'\"; $result=mysql_query($query) or die (\"error: \".mysql_error()); if (mysql_num_rows($result)==1){ session_start(); $_SESSION[\"user\"]=$user; $_SESSION[\"pass\"]=$pass ; $row=mysql_fetch_array($result); if ($row[\'usertype\']==0){ header(\"location:admin_home.php\"); } elseif ($row[\'usertype\']==1) { header(\"location:cashier_home.php\"); } } else echo \"invalid password and username\";
