I am missing something I am sure. If some one could point me in the right dirrection that would be great.
My login page works great untill it executes the output_login() function. If I change the order the user defined functions are declaired it works fine. That would be a fine solution except that I will be calling some but not all of the functions from other pages. And I am sure I will be calling them out of order.
What do I need to do so I can call any of these functions at any time in any order from any page?
Any help that can be offered would be great. Thanks.
here is my login page.
<?php
session_start();
setcookie('TestCookie', '',time() + 3600); //create a new cookie and have it expire in one hour
require_once('include.php');
output_head('page title');
output_logo();
output_login();
output_footer();
?>
here is my include page
<?php
//This single include file will include all of my function files
require_once('db_fns.php');
require_once('output_fns.php');
?>
and here is my output_fns.php page
<?php
/**************************************************************************************************************/
if (!function_exists('output_head'))
{
function output_head($title)//Create HTML Head
{
echo' <!--************* Begin HTML Head *************-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>'.$title.'</title>
<link rel="stylesheet" href="style/style.css" type="text/css">
<meta name="author" content="Joshua Lewis">
</head>
<!--************* Begin HTML Body *************-->
<body>
';
end;
}
}
?>
<?php
/**************************************************************************************************************/
output_logo()//create the heading(logo)
{
echo ' <!--******************* Begin HTML Logo *******************-->
<h3>this will be a logo</h3>';
end;
}
?>
<?php
/*****************************************************************************************************************/
function output_menu()//Create a menu
{
db_connect();
$query = "select * from menu";
$query_result = mysql_query($query)
or die("Invalid query: " . mysql_error());
$num_results = mysql_num_rows($query_result);
echo'<!--******************* Begin NAV MENU *******************-->
';
for ($i=0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($query_result);
echo'<a class="menu" href="'.htmlspecialchars(stripslashes($row['menu_link']))
.'" target="'.htmlspecialchars(stripslashes($row['menu_target']))
.'">'.htmlspecialchars(stripslashes($row['menu_text']))
.'</a><br>
';
}
end;
}
?>
<?php
/*****************************************************************************************************************/
function output_content($page)
{
db_connect();
$query = "select * from user,user_info,post where posts.page = '".$page."'";
$query_result = mysql_query($query)
or die("Invalid query: ". mysql_error());
echo'<!--******************* Begin HTML Content *******************-->
';
for ($i=0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($query_result);
echo '<tr class="post">';
echo ' <td>';
echo ' <p class="block">'.htmlspecialchars(stripslashes($row['subject'])).'<br>';
echo ' <a href="mailto:'.htmlspecialchars(stripslashes($row['email']))'">'.htmlspecialchars(stripslashes($row['username'])).'</a> - '.htmlspecialchars(stripslashes($row['date']))'</p>';
echo " <p>".htmlspecialchars(stripslashes($row['message'])).'</p>';
echo " </td>";
echo "</tr>";
}
end;
}
?>
<?php
/*****************************************************************************************************************/
function output_footer()// print an HTML footer
{
echo'<!--******************* Begin HTML footer *******************-->
</body>
</html>';
end;
}
?>
<?php
/*****************************************************************************************************************/
function output_login()
{
echo '<form action="login_class.php" method="post" name="login" target="self">
<br />
Username: <input name="username" type="text" size="25" maxlength="25" />
<br />
Password: <input name="password" type="password" size="25" maxlength="25" />
<br />
<input name="reset" type="reset" value="Reset" />
<input name="login" type="submit" value="Login" />
</form>
If you do not have an account you may <a href="create_login.php" target="self">create
one here</a>.';
end;
}
?>