[eluser]adamsonit[/eluser]
Undefined index: login in C:\wamp\www\Copy of mathdept\dbconnect\dbconnect.php on line 59
Undefined variable: error in C:\wamp\www\Copy of mathdept\dbconnect\dbconnect.php on line 106
Code:
<?php
mysql_connect('localhost','root',"") or die('cannot connect');
mysql_select_db('mathematics')or die('cannot connect to db');
function loginForm()
{
echo '
<div id="container2">
<div id="nav-right">
<div id="sideright-top"><p class="class2">Log In</p></div>
<div id="sideright-bg">
<form id="form1" name="form1" method="post" action="verify.php?invalid=<?php echo "Invalid Username or Password!"; ?>">
<table width="232" border="0">
<tr>
<td width="72"><p>Username</p></td>
<td width="150"><input name="username" type="text" id="username" /></td>
</tr>
<tr>
<td><p >Password</p></td>
<td><input name="password" type="text" id="password" /></td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td><p >Register</p></td>
<td><input type="submit" name="Submit" value="Login" /></td>
</tr>
</table>
</form>
</div>
<div id="sideright-buttom"></div>';
}
function userInfo($employeeid)
{
$query = "select username' from login where employeeid = '$employeeid'";
$getName = mysql_query($query);
$rowName = mysql_fetch_array($getName);
$name = $rowName['username'];
echo '
<div id="container2">
<div id="nav-right">
<div id="sideright-top"><p class="class2">Welcome, '.$name. '</p></div>
<div id="sideright-bg">
</div>
<div id="sideright-buttom"></div>';
}
function login_lib()
{
if($_POST['login'])
{
$username=$_POST['username'];
$password=$_POST['password'];
//check user if existing
$query = "select *
from login
where
username = '$username'
and password = '$password'
and type !=1 ";
$checkUser = mysql_query($query);
if(mysql_num_rows($checkUser)!=1)
{
$error = true;
$errMsg ='Error trying to validate user!';
}
elseif(mysql_num_rows($checkUser)==1)
{
$row = mysql_fetch_array($checkUser);
$userLevel = $row['type'];
$employeeid=$row['employeeid'];
if($userLevel ==2)
{
$_SESSION['loginSuccess'] = 'success';
$_SESSION['userLevel'] =2;
$_SESSION['employeeid'] = $employeeid;
header("location:index.php");
}
else
{
header("location:/faculty/index.php");
$_SESSION['loginSuccess'] = 'success';
$_SESSION['userLevel'] =3;
$_SESSION['userid'] = $employeeid;
header("location:index.php");
}
}
else
{
header("location:/mathdept");
}
}
return $error;
}
?>