Include() cannot see variables
Posted: Tue Mar 02, 2010 5:40 pm
Hi,
I have a login form in a page. I want to display errors in a formated page. I had to place all the PHP caode in the top of the page due to header functions. The code works but no variables are sent to the included page. Here is the code:
Here is the form in index.php
Here is part of the error checking in index.php
and here is the code in errorpage.php
The $message does not print anthing nor the $testval. I think I did everything correctly.
Let me know if you see the error,
JP
I have a login form in a page. I want to display errors in a formated page. I had to place all the PHP caode in the top of the page due to header functions. The code works but no variables are sent to the included page. Here is the code:
Here is the form in index.php
Code: Select all
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<table border="0" align="center">
<tr>
<td width="144" align="center"><p>Username:</p></td>
</tr>
<tr>
<td><input type="text" name="username" maxlength="15"></td>
</tr>
<tr>
<td align="center">Password:</td>
</tr>
<tr>
<td><input type="password" name="pass" maxlength="15"></td>
</tr>
<tr>
<td align="right"><center>
<input type="submit" name="submit" value="Login">
</center></td>
</tr>
</table>
</form>
<?php
}
Code: Select all
//if the login form is submitted
if (isset($_POST['submit']))
{
//Gives error if user doesnt exist
$check2 = mysql_num_rows($check);
if ($check2 == 0) {
//die('That user does not exist in our database.');
$no_file = "<center><br>Sorry that file could not be found</center>";
$message = $no_file;
$testval = 5;
include("errorpage.php");
exit;
}
Code: Select all
<P><?php
$no_access = "<center><br>Sorry could not connect to the Database</center>";
$no_file = "<center><br>Sorry that file could not be found</center>";
echo $testval;
echo "Error: $message";
echo "<br>look for the error ";
?>
Let me know if you see the error,
JP