Thanks Hockey! Yes, I noticed after posting my php4 function that my 'valids' were missing the $s. Also, the help on the concatenation helped a lot. This was throwing me off more than anything. Thanks again! The form (up to the rest of my commented-out code) works great! :) Ben
bschm78
Posts
-
Can someone help me spot check this form code? -
Can someone help me spot check this form code?That probably would help, eh? :). Here ya go.... Also, just to clarify my program, this is a t-shirt order form and the $paypal and $check variables ccorrespond to checkboxes asking if the user wants to pay by check or with paypal. <html> <head> <title>Validations functions</title> </head> <body> <?php // print "included ok"; function verifyAlphaNum($testString) { if (eregi ("^([[:alnum:]]|-|\.||')+$", $testString)) { return 1; } else { return 0; } } function verifyEmail($testString) { if (eregi ("^([[:alnum:]]|-|\.||')+@([[:alnum:]]|\.|- )+(\.)([a-z]{2, 4})$", $testString)) { return 1; } else { return 0; } } function verifyText($testString) { if (eregi("^([[:alnum:]]|-|\.||\n|\r|\?|\!|\"|\' ')+$", $testString)) { return 1; } else { return 0; } } function verifyPhone($testString) { if(eregi('^([[:digit:]]||-)+$', $testString)) { return 1; } else { return 0; } } ?> </body> </html>
-
Can someone help me spot check this form code?I am writing a simple form for a website I am developing and I keep getting parse errors, mostly dealing with quotes around HTML tags. Here is my code - any guidance would be appreciated. The errors I am getting are creeping up between the following 2 comment tags, to make it easier to identify: /////////////////////////////////////////////////////// //check for existence of missing fields/error messages /////////////////////////////////////////////////////// and /* commented this out for testing of first part of script ///////////////////////////// // WRITE DATA TO MYSQL table ///////////////////////////// Here's my code: <HTML> <HEAD> <TITLE>SHIRT SCRIPT</TITLE> </HEAD> <BODY> <?php include ("validation_functions.php4"); function shirtsSetup() { //////////////////////////////////////// //GET VALUES FROM SHIRT PORTION OF FORM //////////////////////////////////////// $name = ($_POST['name']); $address = ($_POST['address']); $city = ($_POST['city']); $state = ($_POST['state']); $zip = ($_POST['zip']); $email = ($_POST['email']); $phone = ($_POST['phone']); $quantity = ($_POST['quantity']); $size = ($_POST['size']); $color = ($_POST['color']); $price = 15; $shirtTotalPrice = $price * $quantity; $instructions = ($_POST['instructions']); $paypal = ($_POST['paypal']); $check = ($_POST['check']); $to = "myemail@yahoo.com"; $subject = "OMN T-Shirt order"; $message= "$name\n$address\n$city\n$state\n$zip\n$phone\n$email\n$phone\nquantity\n$size\n$color\n$instructions"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; ////////////////////////////// //CHECK FOR ERRONEOUS FIELDS. ////////////////////////////// $error_msg = array(); $valid = verifyAlphaNum($name); if(!valid) { $error_msg[] = "Name must be letters, spaces, dashes and ' only"; } $valid = verifyAlphaNum($address); if(!valid) { $error_msg[] = "Address must be letters, numbers, spaces, dashes and ' only"; } $valid = verifyAlphaNum($city); if(!valid) { $error_msg[] = "City must be letters, spaces, dashes and ' only"; } $valid = verifyAlphaNum($state); if(!valid) { $error_msg[] = "State must be two letters only"; } $valid = verifyAlphaNum($zip); if(!valid) { $error_msg[] = "Zip must contain five numbers only"; } $valid = verifyEmail($email); if(!valid) { $error_msg[] = "Email must be a valid format"; } /////////////////////////////////////////////////////// //