anton_1 Posted March 26, 2012 Share Posted March 26, 2012 <?php $host=""; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="helpdesk"; // Database name $tbl_name="users"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $barcodeID=$_POST['barcode']; // To protect MySQL injection (more detail about MySQL injection) $barcodeID = stripslashes($barcodeID); $barcodeID = mysql_real_escape_string($barcodeID); $sql="SELECT * FROM $tbl_name WHERE BarcodeID='$barcodeID'"; $result=mysql_query($sql); $isAdmin = mysql_fetch_row($result); if ($result['Priority'] = "Admin") { header("location:AdminSection.php"); } else //do I have something missing here? { header("location:index.php"); } // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" $_SESSION['barcode'] = $barcodeSession; $_SESSION['userlevel'] = $row['Priority']; if($row['userlevel'] == "Admin") { header("location:AdminSection.php"); }else{ header("location:index.php"); } header("location:LoggedIn.php"); } else { header("location:index.php"); } ?> When a user has been entered into the database with their priority set to Admin, it will no recognise it? Any help is apprectiated Thanks Link to comment https://forums.phpfreaks.com/topic/259741-user-and-administration-login-page/ Share on other sites More sharing options...
dragon_sa Posted March 26, 2012 Share Posted March 26, 2012 this $isAdmin = mysql_fetch_row($result); if ($result['Priority'] = "Admin") needs to be $isAdmin = mysql_fetch_array($result); if ($isAdmin['Priority'] == "Admin") EDIT: just picked up on the other issue with mysql_fetch_row, that returns the row in an array such as $isAdmin[0], $isAdmin[1] etc Link to comment https://forums.phpfreaks.com/topic/259741-user-and-administration-login-page/#findComment-1331227 Share on other sites More sharing options...
anton_1 Posted March 27, 2012 Author Share Posted March 27, 2012 Thank you mate! Link to comment https://forums.phpfreaks.com/topic/259741-user-and-administration-login-page/#findComment-1331563 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.