Posted by:
stacson
(---.dynamic.dsl.as9105.com)
Hi there,
I'm getting a similar error. I'm trying to set up my login page so it knows who is a user (member) and who is a superuser (administrator) but I am having problems with my code, and keep getting the following error:
Notice: Undefined index: admin in C:\wamp\www\set08101cw2\scripts\login.php on line 16.
My code is as follows:
<?php
session_start();
include("dbconnect.php"
;
$numrows=0;
$pword=trim($_POST['pword']);
$email=trim($_POST['email']);
$query="select email,fname from members where (password=password($pword) && email='$email')";
$link = @ mysql_query($query);
if (!$link) {
$result="0";
die($result);
}
$numrows=mysql_num_rows($link);
if ($numrows>0){
$row = mysql_fetch_array($link, MYSQL_ASSOC);
if($row['admin']==1){
$_SESSION['superuser']=$row['fname'];
} else {
$_SESSION['user']=$row['fname'];
$_SESSION['email']=$row['email'];
}
echo '9';
} else {
echo "1";
}
?>
I'm currently getting the above error message and it is also showing the first echo number (9) under it. I am very new to PHP - are you able to point me in the right direction, as this is driving my crazy!!
Cheers