I am working a building a dynamic web page and i am using functions to do so. I was wondering how or if its possible to have a function call another funciton. This is what i am trying to do. The only part that will change alot would be the contents in the body funciton. I want to pass in display_login_form() to be displayed in the body for this particalue page. The other page titled functions.php contains the layout of the site which i built using functions. I have attached a link so you can see what i have done so far. I know that my programming practice might not be that well so forgive me. I just want to know how i might be able to easily change what is in the display body function either by passing in other functions or by doing it some other way. Thanks for your help.
title - "login.php"
<?php
require_once('output_ozark.php');
do_html_header();
display_menuL();
display_body('display_login_form()');
display_menuR();
do_html_footer();
?>
<!------------------------ Functions.php ----------------------->
title -"functions.php"
<?php
function do_html_header()
{
// print an HTML header
?>
<!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><TITLE>Ozark Valley Triathlon</TITLE>
<?php include("incfiles/i_css.inc"); ?>
<?php include("incfiles/i_menuScript.inc"); ?>
<?php include_once("global/i_connect.php"); ?>
</HEAD>
<BODY>
<!--Top Logo-->
<div id="top_logo">
<img src="images/topheaderlogo%20copy.jpg" />
</div>
<!-- The navigational menu resides here -->
<?php include("incfiles/i_horzMenu.inc"); ?>
<!-- Yellow bar resides here -->
<?php include("incfiles/i_yellowBar.inc"); ?>
<!-- Floating Images below here -->
<div id="runner"><img src="images/runner_sm.gif" /></div>
<div id="bike"><img src="images/bike_sm.gif" /></div>
<?php
}
?>
<?php
function display_menuL()
{
// print out Left Menu
?>
<!-- Body of Page below here -->
<div id="c-block">
<table align="center">
<tr>
<td valign="top" class="lh-col">
<?php include("incfiles/i_menu.inc"); ?>
</td>
<?php
}
?>
<!---------------- Display HTML BODY --------------->
<?php
function display_body()
{
?>
<td class="c-col" valign="top">
<?php display_login_form(); ?>
</td>
<?php
}
?>
<!---------------- Display HTML MenuR --------------->
<?php
function display_menuR()
{
?>
<td valign="top" class="rh-col">
<?php include("incfiles/i_menuR.inc"); ?>
</td>
</tr>
</table>
<?php
}
?>
<?php
function do_html_footer()
{
// print an HTML footer
?>
<div id="bottom_bar"></div>
<div id="copyright"> Copyright © 2004 Ozark Valley Triathlon
Desgined by <a href="http://www.nathanaelmiller.com">Nathanael Miller.</a> </div>
</div>
</div>
</BODY>
</HTML>
<?php
};
?>
<?php
function display_login_form()
{
?>
<a href='register_form.php'>Not a member?</a>
<form method='post' action='member.php'>
<table bgcolor='#cccccc'>
<tr>
<td colspan=2>Members log in here:</td>
<tr>
<td>Username:</td>
<td><input type='text' name='username'></td></tr>
<tr>
<td>Password:</td>
<td><input type='password' name='passwd'></td></tr>
<tr>
<td colspan=2 align='center'>
<input type='submit' value='Log in'></td></tr>
<tr>
<td colspan=2><a href='forgot_form.php'>Forgot your password?</a></td>
</tr>
</table></form>
<?php
}
function display_registration_form()
{
?>
<form method='post' action='register_new.php'>
<table bgcolor='#cccccc'>
<tr>
<td>Email address:</td>
<td><input type='text' name='email' size=30 maxlength=100></td></tr>
<tr>
<td>Preferred username <br />(max 16 chars):</td>
<td valign='top'><input type='text' name='username'
size=16 maxlength=16></td></tr>
<tr>
<td>Password <br />(between 6 and 16 chars):</td>
<td valign='top'><input type='password' name='passwd'
size=16 maxlength=16></td></tr>
<tr>
<td>Confirm password:</td>
<td><input type='password' name='passwd2' size=16 maxlength=16></td></tr>
<tr>
<td colspan=2 align='center'>
<input type='submit' value='Register'></td></tr>
</table></form>
<?php
}
?>
<?php
}
function display_user_menu()
{
// display the menu options on this page
?>
<hr />
<a href="member.php">Home</a> |
<a href="add_bm_form.php">Add BM</a> |
<?php
// only offer the delete option if bookmark table is on this page
global $bm_table;
if($bm_table==true)
echo "<a href='#' onClick='bm_table.submit();'>Delete BM</a> | ";
else
echo "<font color='#cccccc'>Delete BM</font> | ";
?>
<a href="change_passwd_form.php">Change password</a>
<br />
<a href="recommend.php">Recommend URLs to me</a> |
<a href="logout.php">Logout</a>
<hr />
<?php
}
function display_add_bm_form()
{
// display the form for people to ener a new bookmark in
?>
<form name='bm_table' action='add_bms.php' method='post'>
<table width=250 cellpadding=2 cellspacing=0 bgcolor='#cccccc'>
<tr><td>New BM:</td><td><input type='text' name='new_url' value="http://"
size=30 maxlength=255></td></tr>
<tr><td colspan=2 align='center'><input type='submit' value='Add bookmark'></td></tr>
</table>
</form>
<?php
}
function display_password_form()
{
// display html change password form
?>
<br />
<form action='change_passwd.php' method='post'>
<table width=250 cellpadding=2 cellspacing=0 bgcolor='#cccccc'>
<tr><td>Old password:</td>
<td><input type='password' name='old_passwd' size=16 maxlength=16></td>
</tr>
<tr><td>New password:</td>
<td><input type='password' name='new_passwd' size=16 maxlength=16></td>
</tr>
<tr><td>Repeat new password:</td>
<td><input type='password' name='new_passwd2' size=16 maxlength=16></td>
</tr>
<tr><td colspan=2 align='center'><input type='submit' value='Change password'>
</td></tr>
</table>
<br />
<?php
};
function display_forgot_form()
{
// display HTML form to reset and email password
?>
<br />
<form action='forgot_passwd.php' method='post'>
<table width=250 cellpadding=2 cellspacing=0 bgcolor='#cccccc'>
<tr><td>Enter your username</td>
<td><input type='text' name='username' size=16 maxlength=16></td>
</tr>
<tr><td colspan=2 align='center'><input type='submit' value='Change password'>
</td></tr>
</table>
<br />
<?php
};
<?php http://www.ozarkvalleytriathlon.com/loginTest.php