Geert T wrote: > 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. what exactly doesn't it do that you expect it to? > 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, .. it's because your not using plain text as your email format - highly annoying. 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'> is 'validateForm.php' actually correct? leave the 'action' blank to have it post to the current URL (regardless of what it is. > <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 I would consider an include file for a single, static, 7 item array rather over-kill - not that it should be a problem either! > /* 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. > */ > have you tried adding the following line to see what is being posted?: var_dump($_POST, $_GET); > 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 ### DONT STICK '@' IN FRONT OF FUNCTIONS (unless you *really* know what you are doing - if that was the case I garantee you wouldn't have needed post your question) > 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 " {$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 " {$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>"; > } > } > ?> > > > ------------------------------------------------------------------------ > Met MSN Spaces kun je per e-mail je weblog bijwerken. Publiceer leuke > verhalen, foto's en meer! Het is gratis! Het is gratis! > <http://clk.atdmt.com/MSN/go/msnnksac0030000001msn/direct/01/?href=http://www.imagine-msn.com/spaces> > > > ------------------------------------------------------------------------ > > <?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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php