Web Programming Week 4 Old Dominion University Department of Computer Science CS 418/518 Fall 2006 Michael L. Nelson <mln@cs.odu.edu> 9/18/06
HERE document … echo "<title>Go Hokies</title>"; echo "<h1>Hokies rule!</h1>"; echo "<p>"; echo "Frank Beamer is the best coach ever!"; echo "<br>" echo "VT is going to crush $next_opponent!!!" … $hokies<<<SOMETOKEN <title>Go Hokies</title> <h1>Hokies rule!</h1> <p Frank Beamer is the best coach ever! <br>" VT is going to crush $next_opponent!!! SOMETOKEN; echo $hokies;
Neat Usage of HERE <?php … // some code to assemble $header_message // lots of code to assemble $main_message // some code to assemble $footer_message echo $header_message; echo $main_message; echo $footer_message; ?>
Tables Season Record (W-L) <table> <tr> <th>Season</th> <th>Record (W-L)</th> </tr> <td>1993</td> <td>9-3</td> <td>1994</td> <td>8-4</td> … <td>2005</td> <td>11-2</td> </table> Season Record (W-L) 1993 9-3 1994 8-4 1995 10-2 1996 1997 7-5 1998 1999 11-1 2000 2001 2002 10-4 2003 8-5 2004 10-3 2005 11-2
Forms <a href="url2?var1=a&var2=b">click me</a> URL1 URL2
Single URL, Run-time Inclusion <?php … if ($_REQUEST['action'] == "edit") { require "edit.php"; }elsif ($_REQUEST['action'] == "add") { require "add.php"; }elsif ($_REQUEST['action'] == "delete") { require "delete.php"; } else { require "initialpage.php"; } ?> URL1 <form action="url1" method=post> … <input type=radio name=action value=edit> <input type=radio name=action value=add> <input type=radio name=action value=delete> </form> <?php if ($_REQUEST['action'] == "") { require "initialpage.php"; } else { require $_REQUEST['action'] . "php" or die "unknown action!"; } ?>