I am getting an error that I am calling an undefined function, but it is defined, as far as I can see. It is in an included file called functions. Here:
<?PHP
function showRegisterForm ($error) {
echo $error;
?>
<table>
<form name="input" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<tr>
<td>Username: </td>
<td><input type="text" name="user"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td>Re-Type Password:</td>
<td><input type="password" name="rePass"></td>
</tr>
<tr>
<input type="hidden" name="register" value="1">
<td><input type="submit" value="Submit"></td>
</tr>
</form>
</table>
<?PHP
}?>
<?PHP
function showLogInForm ($error) {
echo $error;
?>
<table>
<form name="input" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<tr>
<td>Username: </td>
<td><input type="text" name="user"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<input type="hidden" name="logIn" value="1">
<td><input type="submit" value="Submit"></td>
</tr>
</form>
</table>
<?PHP
}?>
The log in form is the one giving the error, I call it in this script:
<?php
require_once 'dbConnect.php';
require_once 'functions.php';
$error = '';
if ($_POST['logIn'] == 1) { //if the form has been submitted
$userName = $_POST['user'];
$pass = $_POST['pass'];
$query = "SELECT * FROM users WHERE user_name='$userName' AND user_pass='$pass'";
$result = mysql_query($query) or die("connection error.");
if (empty($userName) || empty($pass)) { //are any of the fields empty
$error = "All fields must be filled out.";}
elseif (mysql_num_rows($result) != 1) { //if the username and password combo are not valid
$error = "Invalid username, password combo.";}
else { //log in was successful
$_SESSION['userName'] = $userName;
$_SESSION['loggedIn'] = 1;
echo "Welcome ".$userName." you're logged in.";
header("Location: http://www.thinksnack.com");
}
}
showLogInForm ($error);
?>