scripting process doesn't function

From: Date: Mon, 25 Dec 2006 11:35:47 +0000
Subject: scripting process doesn't function
Groups: php.general 
Request: Send a blank email to php-general+get-246208@lists.php.net to get a copy of this message
Hi, I have made some script that process the users input, and validates the input and sends it back. But it doesn't work very well, in fact it doesn't work at all. I am only able to see and input my name and such in the html form, but the php part doesn't do it's job. I have looked over the scripts thousands of times, but couldn't find the problem, really. Here is the script plus 2 .inc files; Hoping for some replies and answers, Thanks in advance! PS: if this script is a bit messy to read, I have included them in this mail seperately. <?php/* Script name: addressForm.inc * Description: Script displays a form.. */ echo "<html> <head><title>Customer Address</title></head> <body>"; echo "<p align='center'> <form action='validateForm.php' method='POST'> <table width='95%' border='0' cellspacing='0' cellpadding='2'\n"; foreach($labels as $field=>$value) { if(isset($_POST[$field])) { $value = $_POST[$field]; } else { $value = ""; } echo "<tr><td align='right'>{$labels[$field]}</br></td> <td><input type='text' name'$field' size='65' maxlength='65' value='$value'> </td> </tr>"; } echo " </table> <div align='center'> <p><input type='Submit' name='Submit' value='Submit Address'></p></div> </form>";?></body></html> <?php/* Script name: info.inc * Description: creates an array of labels for use in a * form. */ $labels = array( "firstName"=> "First Name:", "midName"=>"Middle Name:", "lastName"=>"Last Name:", "street"=>"Street Address:", "city"=>"City:", "state"=>"State:", "zipcode"=>"Zipcode:"); ?> <?php/* Script name: validateForm * Description: Displays and validates a form that * collects a name and address. */ include("info.inc"); #6 ################################# ## First display of empty form ## ################################# if(!isset($_POST['Submit'])) #10 { include("addressForm.inc"); } ######################################################## ## Check information when form is submitted. Build ## ## arrays of blank and incorrectly formatted fields. ## ## If any errors are found, display error messages ## ## and redisplay form. If no errors found, display ## ## the submitted information. ## ######################################################## else #21 { foreach($_POST as $field=>$value) #23 { if(empty($_POST[$field])) #25 { if($field !="midName") { $blanks[$field] = "blank"; #29 } } else #33 { $value = trim($value); if($field != "zipcode") { if(!ereg("^[A-Za-z0-9' .-]{1,65}$",$value)) { $formats[$field] = "bad"; } } elseif($field == "zipcode") { if(!ereg("^[0-9]{5}(\-[0-9]{4})?",$value)) { $formats[$field] = "bad"; } } } } #51 ### if any fields were not okay, display error ### ### message and redisplay form ### if (@sizeof($blanks) > 0 or @sizeof($formats) > 0) #54 { if (@size($blanks) > 0) { echo "<b>You didn't fill in one or more required fields. You must enter:</b><br>"; foreach($blanks as $field => $value) { echo "&nbsp;&nbsp;&nbsp;{$labels[$field]}<br>"; } } if (@sizeof($formats) > 0) { echo "<b>One or more fields have information that appears to be incorrect. Correct the format for:</b><br>"; foreach($formats as $field => $value) { echo "&nbsp;&nbsp;&nbsp;{$labels[$field]}<br>"; } } echo "<hr>"; include("adressForm.inc"); } else { ### If no errors in the form, display the ### ### name and address submitted by user ### echo "<html><head><title>Name and Address </title></head><body>\n"; foreach($_POST as $field=>$value) { if($field != "Submit") { echo "{$labels[$field]} $value<br>\n"; } } echo "</body></html>"; } } ?> _________________________________________________________________ Probeer Live.com: jouw leven online met nieuws, sport, weer en nog veel meer. http://www.live.com/getstarted

<?php /* Script name: addressForm.inc * Description: Script displays a form. */ echo "<html> <head><title>Customer Address</title></head> <body>"; echo "<p align='center'> <form action='validateForm.php' method='POST'> <table width='95%' border='0' cellspacing='0' cellpadding='2'\n"; foreach($labels as $field=>$value) { if(isset($_POST[$field])) { $value = $_POST[$field]; } else { $value = ""; } echo "<tr><td align='right'>{$labels[$field]}</br></td> <td><input type='text' name'$field' size='65' maxlength='65' value='$value'> </td> </tr>"; } echo " </table> <div align='center'> <p><input type='Submit' name='Submit' value='Submit Address'></p></div> </form>"; ?> </body></html><?php /* Script name: info.inc * Description: creates an array of labels for use in a * form. */ $labels = array( "firstName"=> "First Name:", "midName"=>"Middle Name:", "lastName"=>"Last Name:", "street"=>"Street Address:", "city"=>"City:", "state"=>"State:", "zipcode"=>"Zipcode:"); ?>
« previous php.general (#246208) next »