i have te below user login page - it is working fine, but i need to add an admin login. I have a admin user table, but am unsure how to get them to log in using the code below, any ideas.
<?php
session_start(username);
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
//Declare the variables
$userName=$_POST['username'];
$password=$_POST['password'];
$conn = mysql_connect("localhost", "root", "") or die('could not connect to mysql' .mysql_error());
mysql_select_db('customer', $conn) or die('could not connect to DB' .mysql_error());
//make the query
$result=mysql_query ("select * from customerdetails where userName='$userName' AND password='$password'");
//check that at least one row was returned
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0){
while($row = mysql_fetch_array($result)){
//successful login forward page
header( "Location: checkLoginOK.php" );
}
}
else {
//if nothing is returned by the query, unsuccessful login code goes here...
//echo 'Incorrect login name or password. Please try again.';
header( "Location: errorLogin.php" );
}
?>
check login page
<?php
$userName=$_SESSION['username'];
//database connection
$conn = mysql_connect("localhost", "root", "") or die('could not connect to mysql' .mysql_error());
mysql_select_db('customer', $conn) or die('could not connect to DB' .mysql_error());
//this needs to be modified to take the value in the username session
$query = "SELECT * FROM customerdetails WHERE userName like '$userName' ";
//show user details on my account
$result = mysql_query ($query)
or die ("Query failed: ".mysql_error());
//displays the amount in users account
echo "<table border = '0' font size = '6'>";
while ($row = mysql_fetch_array($result))
{
echo "<tr >
<td width = '15%'></td>
<td width = '22%'></td>
<td width = '63%' rowspan ='100%'><img align = 'right' src = 'images/FootballOddsLogo.gif'/></td></td>
</tr>
<tr>
<td><b>Welcome back : </b></td>
<td>",$row['userName'],"</td><td></td>
</tr>
<tr>
<td><b>Current Balance :</td>
<td><a href ='CheckLoginOK.php'>",$row['amount'],"</a></b></td>";
echo "</tr>";
echo "<tr >
<td><a href = 'myaccount.php' target='showframe' >My Account</a></td>
<td><a href = 'logout.php'>Log out</a></td>
<td></td>
</tr>";
}
echo "</table>";
?>