Hi i'm trying to create a login page that compares the input of a form to the info in a mysql database which obviously decides weather the user has rights to access.
This is the code:
<?php include("header.inc");?>
<h2>Login</h2>
<?
//open db connection
$link=mysqli_connect('localhost','root','*****','JobBase');
$select="SELECT Password, Status FROM Members WHERE UserName = $UserName";
$result= mysqli_query($link, $select);
//check that record exists
if(mysqli_num_rows($result)<1) {
"This username does not exist in our database, please try again";
} else {
//assign results to an array
$row=mysqli_fetch_array($result);
//get each array element and give it a variable name of its own
$pass = $row['Password'];
$stat = $row['Status'];
mysqli_close($link);
if($Password == $pass) {
if($stat == 1) {
"goto advertisers page";
} else {
"goto search page"; }
} else {
"Your password and username do not match, please try again";}}
?>
<FORM method="post" action="<? echo '$_SERVER[PHP_SELF]'?>">
<TABLE>
<TR><TD>UserName:</TD><TD><input type="text" name="UserName" VALUE="<?echo $UserName?>"/></TD></TR>
<TR><TD>Password:</TD><TD><input type="password" name="Password" VALUE="<?echo $Password?>"/></TD></TR>
</TABLE>
<INPUT TYPE="Button" VALUE="Login">
</FORM>
</body>
</HTML>
At the moment i am getting the following errors:
Notice: Undefined variable: UserName in C:\Program Files\Apache Group\Apache2\htdocs\Login.php on line 9
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\Program Files\Apache Group\Apache2\htdocs\Login.php on line 14
Can anyone explain them to me. The first notice, i want it to be reading the input from the form at the bottom.
Also at the moment i have simply put in strings saying to "goto search page" etc.....how do i get it to actually go to another .php page??
Please help me
Thank you