";
print $string;
print "";
}
// ---------------------------------------------
function font_bold($string="") {
print "";
print "$string";
print "";
}
// ---------------------------------------------
function open_table($thing1="") {
print "
\n";
print "\n";
font_bold($thing1);
print " | \n";
print "\n";
}
// ---------------------------------------------
function close_table() {
print " | \n";
print "
\n";
}
// ---------------------------------------------
function show_form($email="", $date="", $url="", $u_name="") {
print "";
}
// ---------------------------------------------
function url_good($url="") {
return eregi("^http://[A-Za-z0-9\%\?\_\:\~\/\.-]+$",$url);
}
// ---------------------------------------------
function make_link($url="", $name="") {
if (empty($name)) $name = $url;
return "$name \n";
}
// ---------------------------------------------
function pretty_date($date) {
if ($date == "0000-00-00") {
return "None";
}
else {
$d = substr($date, -2);
$m = substr($date, -5, -3);
$y = substr($date, 0, 4);
return date("M d, Y", mktime (0,0,0,$m,$d,$y));
}
}
// ---------------------------------------------
function process_input($email, $date, $url, $u_name) {
$pretty_date = pretty_date($date);
$link = make_link($url, $u_name);
print "Thank you!
";
print "You entered the following:";
print "
";
open_table("E-mail");
print "$email";
close_table();
open_table("Birthday");
print "$pretty_date";
close_table("Please use YYYY-MM-DD");
open_table("URL");
print "$link";
close_table();
print "
";
}
// ---------------------------------------------
function email_good($email="") {
// figure out what the regex should be
$regex = '';
return eregi($regex ,$email);
}
function check_input($email, $date, $url, $u_name) {
$str = "";
if (!email_good($email)) {
$str .= "Your email address does not look correct
";
}
// figure out what the regex should be
if (!ereg('', $date)) {
$str .= "Your date does not look correct
";
}
if (!url_good($url)) {
$str .= "Your URL does not look correct
";
}
return $str;
}
// ---------------------------------------------
// main()
if (!isset($email)) {
show_form();
}
else {
$err_msg = check_input($email, $date, $url, $u_name);
if (!empty($err_msg)) {
print "$err_msg
";
check_input($email, $date, $url, $u_name);
show_form($email, $date, $url, $u_name);
}
else {
process_input($email, $date, $url, $u_name);
}
}
?>