I'm new to making websites and I'm really not sure what I've done wrong, but each time I try to preview my page within a browser or on the ftp site I get this error message:
Fatal error: Call to undefined function mmysql_select_db() in
/home/cattho15/studentexcavation2015.co.uk/multipage files/loginpage.php on line 55
Although I can't see anything wrong with the coding I've used.
Here's the code:
<?php require_once('../Connections/User_login_information.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "login_form")) {
$insertSQL = sprintf("INSERT INTO user_id_login (username, Password) VALUES (%s, %s)",
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['password'], "text"));
mysql_select_db($database_User_login_information, $User_login_information);
$Result1 = mysql_query($insertSQL, $User_login_information) or die(mysql_error());
$insertGoTo = "INDEX.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mmysql_select_db($database_User_login_information, $User_login_information);
$query_User_Login = "SELECT * FROM user_id_login";
$User_Login = mysql_query($query_User_Login, $User_login_information) or die(mysql_error());
$row_User_Login = mysql_fetch_assoc($User_Login);
$totalRows_User_Login = mysql_num_rows($User_Login);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "INDEX.php";
$MM_redirectLoginFailed = "redirect page.html";
$MM_redirecttoReferrer = false;
mysql_select_db($database_User_login_information, $User_login_information);
$LoginRS__query=sprintf("SELECT username, Password FROM user_id_login WHERE username=%s AND Password=%s",
GetSQLValueString($loginUsername, ""), GetSQLValueString($password, ""));
$LoginRS = mysql_query($LoginRS__query, $User_login_information) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>