With one problem solved, here comes the next one.
When executing the code I get the following error:
Warning: Cannot modify header information - headers already sent by (output started at d:\php\verify.php:36) in d:\php\verify.php on line 51
This error refers to the line highlighted in bold below:
<?
// Include DB Variables
include("config.php");
// Check Querystring for variables passed, labelled $user_name + $password to avoid confusion with config.php $username, $password
$user_name = $HTTP_POST_VARS['username'];
$pass_word = $HTTP_POST_VARS['password'];
// Check user_name and password.
if((!$user_name) | (!$pass_word)) {
print ("Please re enter your login information");
}
// Connect To MySQL Server
mysql_connect($server, $username, $password) or die("Couldn't Connect to Database");
// Select Database
mysql_select_db($database) or die("Couldn't Select Database");
//Encrypt the password variable before sending to the database
//$pass_word = md5($pass_word);
// SQL Query
$sql = "select * from username where password='$pass_word' and username='$user_name'";
// Run the SQL dynamically, by placing in the mysql_query field
$sql_result = mysql_query($sql);
// count number of matches
$num = mysql_numrows($sql_result);
# If Login Is Okay Do What You Want TO DO to Them
if ($num == "1") {
print "<span class=general>Logged in okay</span>";
}
# And we must a have a default error message if login fails
if ($num == "0"){
print "<span class=general>Sorry the details you provided do not match any existing records.</span>";
} else {
while ($row = mysql_fetch_array($sql_result)){
$userlevel = $row["userlevel"];
echo $userlevel;
}
if ($userlevel = "admin"){
[b]header("Location: [url]http://localhost/admin/control.php[/url]");[/b]
exit;
} elseif ($userlevel = "user"){
header("Location: [url]http://localhost/user/control.php?user=[/url]$user_name");
exit;
}
}
?>