<?php
// connection to MySQL server
mysql_connect('localhost','root','root');
mysql_select_db('administration');
// *** Validate request to login to this site.
//session_start();
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_register('PrevUrl');
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
//$MM_fldUserAuthorization = "level_usr";
$MM_redirectLoginSuccess = "validated.php";
$MM_redirectLoginFailed = "index.html";
$MM_redirecttoReferrer = true;
//mysql_select_db($database_connBlog, $connBlog);
mysql_select_db($database, $administration);
$LoginRS__query=sprintf("SELECT username, password FROM adminprofile WHERE username='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $adminprofile) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
// $loginStrGroup = mysql_result($LoginRS,0,'level_usr');
//declare two session variables and assign them
// $GLOBALS['MM_Username'] = $loginUsername;
//$GLOBALS['MM_UserGroup'] = $loginStrGroup;
//register the session variables
//session_register("MM_Username");
//session_register("MM_UserGroup");
if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
errors:
1.Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in D:\xampp\htdocs\cycle\validate.php on line 34
2.Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in D:\xampp\htdocs\cycle\validate.php on line 38
Please help as I couldn't make the code to check my username and password from the login page and validate it with the information stored in the database.