Search the Community
Showing results for tags 'error help'.
-
please i've been trying to create a registration form for my website and it seems like its taking forever..... i've got some error of which i have tried to rectify but to no avail, so decided post the code and the error to see if someone might be of help to me <?php $required=array("fname" => "Firstname", "lname" => "Lastname", "email" => "Email address", "password" => "Password"); foreach ($required as $field => $label) { if (isset($_POST[$field])) { $warnings[$field] = "Required"; } } if (isset($_POST["email"])&& !ereg("^[^@]+@([a-z\-]+\.)+[a-z]{2,4}$", $_POST["email"])) $warnings["email"] = "Invalid email"; if (isset($_POST["telephone"])&& !ereg("^\([[:digit:]]{3}\)[[:digit:]]{4}-[[:digit:]]{4}$", $_POST["telephone"])) $warnings["telephone"] = "Must be (555)0000-0000"; $password=$_POST["password"]; $salt=rand(100000,999999); $encrypted= (md5($salt.$password)); if (empty($warnings) > 0) { ?> <form action = "register.php" method=post> <table border=0> <tr> <td>Firstname:</td> <td><input type=text size=30 name="fname" value="<?php echo (isset($_POST["fname"])? $_POST ["fname"]:"");?>" > </td> <td><?php echo (isset($warnings["fname"])? $warnings["fname"]:"");?> </td> </tr><br/> <tr> <td>Lastname:</td> <td><input type=text size=30 name="lname" value="<?php echo (isset($_POST["lname"])? $_POST ["lname"]:"");?>"> </td> <td><?php echo (isset($warnings["lname"])? $warnings["lname"]:"");?> </td> </tr> <tr> <td>Email address:</td> <td><input type=text size=30 name="email" <?php if (isset($warnings["email"])) echo "STYLE=\"shaded\"";?> value="<?php echo (isset($_POST["email"])? $_POST["email"]:"");?>"> </td> <td><?php echo (isset($warnings["email"])? $warnings["email"]:"");?> </td> </tr> <tr> <td>Password:</td> <td><input type=password size=30 name="password" value="<?php echo (isset($_POST["password"])? $_POST["password"]:"");?>"> </td> <td><?php echo (isset($warnings["password"])? $warnings[password]:"");?> </td> </tr> <tr> <td>Telephone:</td> <td><input type=text size=30 name="telephone" value="<?php echo (isset($_POST["telephone"])? $_POST["telephone"]:"")?>"> </td> <td><?php echo (isset($warning["telephone"])? $warnings["telephone"]:"");?> </td> </tr> <tr> <td>sex:</td> <td><?php include("sex.php"); ?> </td> <td></td> </tr> <tr> <td>Date of birth:</td> <?php $menu = generate_menu("year", $endYear = '', $startYear = '1900'); function generate_menu($name, $endYear = '', $startYear = '1900' ) { $selected = "<SELECT NAME=\"$name\">"; for ( $i = $startYear; $i <= $endYear; $i++ ) { $selected .= "<OPTION "; ( $i == date('Y') ) ? $selected .= "selected='selected'" : $selected = ''; $selected .= "value=\'$i\'>$i</OPTION>"; } $selected .= "</SELECT>"; return($selected); } ?> <? $month = array(1=> "Jan", 2=> "Feb", 3=> "Mar", 4=> "Apr", 5=> "May", 6=> "Jun", 7=> "Jul", 8=> "Aug", 9=> "Sep", 10=> "Oct", 11=> "Nov", 12=> "Dec"); $default = "1"; $option = generate_menu("month", $month, $default); function generate_menu($name, $month, $default="") { $select = "<SELECT NAME=\"$name\">"; foreach($month as $value => $label) { $select .= "<OPTION "; if ($value == $default) $select .= "selected='selected'"; $select .= "value=\'$value\'>$label</OPTION>"; } $select .= "</SELECT>"; return($select); } ?> <? $function = generate_menu("day"); function generate_menu($name) {$sel = "<SELECT NAME=\"$name\">"; for ( $i = 1; $i <= 31; $i++ ) { $sel .= "<OPTION "; ( $i == date('j') ) ? $sel .= "selected='selected'" : $sel = ''; $sel .= "value=\'$i\'>$i</OPTION>"; } $sel .= "</SELECT>"; return($sel); } ?> <td> <?php print $menu;?> </td> <td> <?php print $option;?> </td> <td> <?php print $function;?> </td> </tr> </TABLE> <INPUT TYPE=SUBMIT VALUE="Register"> </form> <?php } else { echo "Thank you for registering"; } ?> error Fatal error: Call to undefined function generate_menu() in C:\xampp\htdocs\form.php on line 65