Jump to content

Login with Admin


anton_1

Recommended Posts

Any help would be greatly appreciated!

 

 

<?php

$host="localhost"; // Host name

$username="user"; // Mysql username

$password=""; // Mysql password

$db_name=""; // Database name

$tbl_name=""; // Table name

 

 

mysql_connect("$host", "$username", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

 

 

$barcodeID=$_POST['barcode'];

 

echo $barcodeID;

 

 

$barcodeID = stripslashes($barcodeID);

$barcodeID = mysql_real_escape_string($barcodeID);

 

 

$sql="SELECT * FROM $tbl_name WHERE BarcodeID='$barcodeID'";

 

 

 

 

$result=mysql_query($sql);

 

// Mysql_num_row is counting table row

$count=mysql_num_rows($result);

$count=mysql_num_rows($result);

 

 

if($count==1){

 

$_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 the script has been run, I want it to redirect to either the user page or admin page depending on their priority level.

 

if Priority field == "Admin" then go to admin page.

 

Can you see anything missing?

 

 

Thank You

 

 

 

Link to comment
Share on other sites

You never fetched the row.

<?php

$host="localhost"; // Host name

$username="user"; // Mysql username

$password=""; // Mysql password

$db_name=""; // Database name

$tbl_name=""; // Table name

 

 

mysql_connect("$host", "$username", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

 

 

$barcodeID=$_POST['barcode'];

 

echo $barcodeID;

 

 

$barcodeID = stripslashes($barcodeID);

$barcodeID = mysql_real_escape_string($barcodeID);

 

 

$sql="SELECT * FROM $tbl_name WHERE BarcodeID='$barcodeID'";

 

 

 

 

$result=mysql_query($sql);

 

// Mysql_num_row is counting table row

$count=mysql_num_rows($result);

$row=mysql_fetch_row($result);

 

 

if($count==1){

 

$_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"); 

}

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.