00001 <?php 00020 function display_add_form($action, $message) 00021 { 00022 ?> 00023 <html> 00024 <head> 00025 <title>Add numbers form</title> 00026 </head> 00027 <body> 00028 <h3>Add two numbers:</h3> 00029 <?php echo $message; ?> 00030 <form action="<?php echo $action; ?>" method="GET"> 00031 Number 1 : <input type="text" name="num1" value=""/> <br/> 00032 Number 2 : <input type="text" name="num2" value=""/> <br/> 00033 <input type="submit" name="submit1" value="Add"/> <br/> 00034 </form> 00035 <?php display_links(); ?> 00036 </body> 00037 </html> 00038 <?php 00039 } 00040 00041 00050 function check_and_get($variable1) 00051 { 00052 if(isset($_GET[$variable1])) 00053 return $_GET[$variable1]; 00054 else 00055 die("$variable1 not passed as GET variable. Exiting <br/>\n"); 00056 } 00057 00058 00064 function display_links() 00065 { 00066 echo "<h3>Related pages:</h3>\n"; 00067 echo "<ol>\n"; 00068 echo "<li><a href='index.php'>Add two numbers using two PHP pages. One page displays 00069 form and other adds values </a></li>\n"; 00070 echo "<li><a href='add2.php'>Add two numbers using single PHP pages. Same page displays 00071 form and also adds values </a></li>\n"; 00072 echo "<li><a href='add3.php'>Add two numbers using single PHP page. Now form is displayed 00073 even while displays sum so that next two numbers can be added easily.</a></li>\n"; 00074 echo "</ol>\n"; 00075 } 00076 00077 00078 ?>