\n"; //the form was submitted //put the post array into vars $firstname = strip_tags(trim($_POST['fname'])); $surname = strip_tags(trim($_POST['sname'])); $phone = strip_tags(trim($_POST['phone'])); $email = strip_tags(trim($_POST['email'])); //values from the hidden vars $identifier = $_POST['identifier']; //inititialise an error array $errors = array(); //validate the user input if(!valid_textfield($firstname)) { $errors[] = 'Firstname must be filled in and contain text only'; } if(!valid_textfield($surname)) { $errors[] = 'Surname must be filled in and contain text only'; } if(!is_numeric($phone)||(strlen($phone)<6)) { $errors[] = 'Telephone must be a number at least 6 digits long'; } if(!valid_email($email)) { $errors[] = 'Email must be in the following format - name@yourdomain.com'; } //check the value of the error variable //if there were no errors, then we process if (count($errors)== 0) { //attempt to insert into the db if(insert_user_registration($firstname, $surname, $email, $phone, $identifier)) { //send the email to the admin address send_preorder_email($firstname, $surname, $email, $phone); echo "\t\t

Thankyou…

\n"; echo "\t\t

Your details have been submitted. We will contact you via email prior to the release date of August 3rd 2006, so that you are one of the first to have the chance to purchase online.

\n"; } else { echo "\t\t

Error…

\n"; echo "\t\t

There was a problem submitting your details. Please try again later.

\n"; } } else { //there were errors so display them echo "\t\t

The following errors occurred:

\n"; echo "\t\t\n"; //display the form display_preorder_forms($_POST); } } //preorder form was NOT submitted else { //display the sub_nav display_sub_nav(); //display the side_nav display_side_nav(); echo "\t
\n"; //display the form to pre order the book display_preorder_forms($_POST); } //close main content div echo "\t
\n"; //display the html footer display_html_footer(); } ?>