この「ログイン」ページを書きましたが、昨夜、エラー メッセージが表示されないことを除けば、すべて正常に機能しました。今日、自分の作業を再確認したところ、次のエラー メッセージが表示されました: Call to undefined function showForm() in E:\wwwroot\teamc\logIn.php on line 7. コードを昨夜から今朝。エラーメッセージが表示される理由を誰でも見ることができますか??
<?php
session_start();
//validate text was entered in UserName text box
if(empty($_POST['txtUserName']))
{
showForm('Please Enter A User Name.');
exit();
}
else
{
$UserName = $_POST['txtUserName'];
}
//validate text was entered in password text box
if(empty($_POST['txtPassword']))
{
showForm('Please Enter A Password.');
exit();
}
else
{
$Password = $_POST['txtPassword'];
}
if($Password != Password($UserName))
{
showForm('User Name And Password Do Not Match!');
exit();
}
function Password($UserName)
{
//database login
$dsn = 'mysql:host=XXX;dbname=XXX';
$username='XXX';
$password='XXX';
//variable for errors
$options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
//try to run code
try {
//object to open database
$db = new PDO($dsn,$username,$password, $options);
//check username against password
$SQL = $db->prepare("Select USER_PASSWORD FROM user WHERE user_name = :UserName");
$SQL->bindValue(':UserName', $UserName);
$SQL->execute();
$username = $SQL->fetch();
if($username === false)
{
$password = null;
}
else
{
$password = $username['USER_PASSWORD'];
include 'index.php';
}
return $password;
$SQL->closeCursor();
$db = null;
} catch(PDOException $e){
$error_message = $e->getMessage();
echo("<p>Database Error: $error_message</p>");
exit();
}
}
function showForm($formMessage)
{?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1 /DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>WisCon Log In</title>
<link rel="stylesheet" href="styles/wiscon-default-styles.css" type="text/css" />
<link rel="stylesheet" href="styles/FormStyle.css" type="text/css" />
<script type="text/javascript" src="js/validateLogInForm.js/validateLogInForm.js"> </script>
</head>
<body id="logPage">
<div id="wrapper">
<?php include('includes/header.php'); ?>
<?php include('includes/topNavigation.php'); ?>
<div id="mainContent">
<div class="formDiv">
<form name="registerForm" id="registerForm" action="" method="post">
<h1 style="color:#FF530D; text-align: center">Log into your account here!</h1>
<fieldset id="security">
<legend>Security</legend>
<label for="txtUserName" class="boxLabel">User Name:</label>
<input type="text" id="txtUserName" name="txtUserName" autofocus="autofocus" required="required" />
<script type="text/javascript">
if(!("autofocus" in document.createElement("input")))
{
setTimeout(function(){
document.getElementById("txtUserName").focus();
}, 10);
}
</script>
<label for="txtPassword" class="boxLabel">Password:</label>
<input type="password" id="txtPassword" name="txtPassword" required="required" />
</fieldset>
<fieldset id="submission">
<div id="buttons">
<input type="submit" id="btnSubmit" name="btnSubmit" value="Submit" onclick="return validateLogInForm()"/>
<input type="reset" id="btnReset" name="btnReset" >
</div><!--end buttons-->
</fieldset>
</p>
</form>
</div><!--end div class=formDiv-->
</div><!--end div id=mainContent-->
<?php include('includes/footer.php'); ?>
</div><!--end div id=wrapper-->
</body>
</html>
<?php
}
?>