Jump to content

Oscar11

New Members
  • Posts

    7
  • Joined

  • Last visited

Oscar11's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have looked at your comments and done some research and now my form is displaying the 'some fields are required' message but all required fields are complete. Ideally I would have a small error box appear on the form page if the user submits but leaves a required field blank? What do you mean by paste the code in [ ] tags? <?php if(isset($_POST['email'])) // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "xxxxx@xxxxxxx"; $email_subject = "Your email subject line"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } if (empty($_REQUEST[$Name])) { echo 'Please go back and fill out ' . $fieldName . "<br>\n"; } // validation expected data exists if(!isset($_POST['name'])) !isset($_POST['email']) || died('We are sorry, but there appears to be a problem with the form you submitted.'); //required fields $first_name = $_POST['name']; // required $email_from = $_POST['email']; // required //error message $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$name)) { $error_message .= 'The Name you entered does not appear to be valid.<br />'; } if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Name: ".clean_string($name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($email_to, $email_subject, $email_message, $headers); ?>
  2. Am learning to understand this language. I have an error message of Parse error: parse error, unexpected T_IF, expecting '{' in /tier-11/pwpstore4/48/tfeethowsthis/htdocs/send_form_emailtest1.php on line 12 The user must fill in their name and email address in order to submit the form. Many thanks <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "xxxxx@xxxxxxx"; $email_subject = "Your email subject line"; function died($error) if (empty($_REQUEST[$Name])) { echo 'Please go back and fill out ' . $fieldName . "<br>\n"; // validation expected data exists if(empty($_POST['name']) || empty($_POST['email']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } if ((!name) || (!email) || (comments)) { $errorMsg = 'Please make sure you have filled in the required fields:<br /><br />'; } if (!$name) { $errorMsg = 'Please fill in your Full Name<br />'; } if (!$email) { $errorMsg = 'Please fill in your email address<br />'; } } [php]
  3. My code isn't working and I have put it into notepad++ and using a php error checker. I want to put the code on here for help but know that you like it presented in a certain way to make life easier for all concerend. How do I indent the code properly on here? Ideally I don't want the form submitted unless certain fields are filled in. A pop up box which says please fill in your ...... . <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "xxxxx@xxxxxxx"; $email_subject = "Your email subject line"; function died($error) { { // Does this field have a value? if (empty($_REQUEST[$fieldName])) { echo 'Please go back and fill out ' . $fieldName . "<br>\n"; // validation expected data exists if(empty($_POST['first_name']) || empty($_POST['last_name']) || empty($_POST['email']) || empty($_POST['telephone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } if ((!first_name) || (!second_name)) { $errorMsg = 'Please make sure you have filled in the required fields:<br /><br />'; if (!$first_name) { $errorMsg = 'Please fill in your First Name<br />'; } if (!$seond_name) { $errorMsg = 'Please fill in your Second Name<br />'; } if (!$mobile_number) { $errorMsg = 'Please fill in your contact number<br />'; } if (!$email) { $errorMsg = 'Please fill in your email address<br />'; } } //strip lashes $first_name = stripslashes($name); $second_name = stripslashes($second_name); $phone = stripslashes($phone); $email = stripslashes($email); //clean string $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers);
  4. Have tidied up form and found some missing parenthese. Form seems to be working but i do want to highlight the fields that don't get filled in. How do I do this please? php if ($_POST ['formsubmit'] == 'submit') { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "xxxxxxxxx"; $email_subject = "Enquiry Form"; function died($error) { // your error code can go here echo "We're sorry, but there were errors found with the form you submitted.<br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if (!isset($_POST['first_name']) || if (!isset($_POST['last_name']) || if (!isset($_POST['home_address']) || if (!isset($_POST['post_code']) || if (!isset($_POST['is_the_student_resident_at_this_address']) || if (!isset($_POST['email']) || if (!isset($_POST['mobile_number']) || if (!isset($_POST['students_first_name']) || if (!isset($_POST['students_last_name']) || if (!isset($_POST['subject_required']) || if (!isset($_POST['level_of_subject']) || if (!isset($_POST['nature_of_help_required'])) { if (!isset($_POST['able_to_travel']) || died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $home_address = $_POST['home_address']; // required $post_code = $_POST['post_code']; // required $is_the_student_resident_at_this_address = $_POST['is_the_student_resident_at_this_address']; // required $email_from = $_POST['email']; // required $mobile_number = $_POST['mobile_number']; // required $students_first_name = $_POST['$students_first_name']; // required $students_last_name = $_POST['$students_last_name']; // required $subject_required = $_POST['subject_required']; // required $level_of_subject = $_POST['level_of_subject']; // required $nature_of_help_required = $_POST['nature_of_help_required']; // required $able_to_travel = $_POST['able_to_travel']; // required // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); header( "Location: http://www.tfeethowsthis.webspace.virginmedia.com/thankyou.html" ); } else { $body = " From: $title_field\n\n Your_first_name: $your_first_name_field\n\n Your_second_name: $your_second_name_field\n\n Your_home_address: $your_home_address_field\n\n Post_code: $post_code_field\n\n Email: $email_field\n\n $landline_number\n\n Mobile_phone: $mobile_phone_field\n\n Subject_required: $subject_required_field\n\n Level_of_study: $level_of_study_field\n\n Name_of_school: $name_of_school_field\n\n Nature_of_help: $nature_of_help_required_field\n\Able_to_travel: n $able_to_travel_field\n\n "; ?>
  5. I am new to php. Please advise me where I am going wrong. <?php if ($_POST ['formsubmit'] == 'submit') { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "xxxxxxxxxxxx"; $email_subject = "Enquiry Form"; function died($error) {
  6. I am designing a site where, if the student is under 19, they get transferred to the client page. Where am I going wrong as it's not working. Should I use a checkbox or a radiobox? Many thanks This is my HTML code for the : <form name ="contactform" action="send_form_email.php" method="post"> <br> <table width="900" border="0" align="center" cellpadding="3" cellspacing="0"> <div align="center"><span class="style18">Student Enquiry Form</span></div> <tr> <td></td> <td align="left"> <input type="radio" class="radio" rel="clientdetails.php"> <?php if($("input[@name=under19]:checked").val()=="private") { attr("action"clientdetails.php"); ?>php <span class="style8"> The student is under 19</span></td> </tr> This is the PHP code: <?php if(isset($_POST['email'])) { // CHANGE THE TWO LINES BELOW $email_to = "ftnby@yahoo.com"; $email_subject = "Tuition enquiry form"; } function died($error) { // your error code can go here echo "We're sorry, but there's errors found with the form you submitted.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; } // your required code can go here if (empty($_POST["your_first_name"])) {$nameErr = "Name is required";} else {$name = test_input($_POST["name"]);} if (empty($_POST["your_surname"])) {$nameErr = "Name is required";} else {$name = test_input($_POST["name"]);} if (empty($_POST["email"])) {$emailErr = "Email is required";} else {$email = test_input($_POST["email"]);} if (empty($_POST["home_address"])) {$nameErr = "Address is required";} else {$name = test_input($_POST["address"]);} if (empty($_POST["post_code"])) {$nameErr = "Post code is required";} else {$name = test_input($_POST["post_code"]);} if (empty($_POST["landline_number"])) {$numberErr = "Please provide a Landline or Mobile number";} else {$number = test_input($_POST["comment"]);} if (empty($_POST["students_first_name"])) {$nameErr = "Name is required";} else {$name = test_input($_POST["name"]);} if (empty($_POST["students_surname"])) {$nameErr = "Name is required";} else {$name = test_input($_POST["name"]);} if (empty($_POST["subject_required"])) {$nameErr = "Subject is required";} else {$name = test_input($_POST["name"]);} if (empty($_POST["level_of_study"])) {$nameErr = "Level_of_Study is required";} else {$name = test_input($_POST["name"]);}
  7. Please advise me where the error is please? , An parse error has come back as unexpected $ on line 115. I also need help with another two areas - I have two enquiry forms [one for the student and one for the client]. The student form has, at present, a radio box which the student clicks on if they are under 19 and this would take them to the client page. Once I have submitted the form I want a confirmation page to appear. How do I do this please? Should the coding be in the script or the htmll form? <?php if (isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "ftnby@yahoo.com" ; $email_subject = "My enquiry to you"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); // validation expected data exists if(!isset($_POST['your_first_name']) || !isset($_POST['your_surname']) || !isset($_POST['your_home_address']) || !isset($_POST['post_code']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } if (empty($_POST["your_first_name"])) {$nameErr = "Name is required";} else {$name = test_input($_POST["name"]);} if (empty($_POST["your_surname"])) {$nameErr = "Name is required";} else {$name = test_input($_POST["name"]);} if (empty($_POST["email"])) {$emailErr = "Email is required";} else {$email = test_input($_POST["email"]);} if (empty($_POST["home_address"])) {$nameErr = "Address is required";} else {$name = test_input($_POST["address"]);} if (empty($_POST["post_code"])) {$nameErr = "Post code is required";} else {$name = test_input($_POST["post_code"]);} if (empty($_POST["landline_number"])) {$numberErr = "Please provide a Landline or Mobile number";} else {$number = test_input($_POST["comment"]);} if (empty($_POST["students_first_name"])) {$nameErr = "Name is required";} else {$name = test_input($_POST["name"]);} if (empty($_POST["students_surname"])) {$nameErr = "Name is required";} else {$name = test_input($_POST["name"]);} if (empty($_POST["subject_required"])) {$nameErr = "Subject is required";} else {$name = test_input($_POST["name"]);} if (empty($_POST["level_of_study"])) {$nameErr = "Level_of_Study is required";} else {$name = test_input($_POST["name"]);} if(!count($errors) && mail($to, $subject, $body, $headers)){ $error_message = ""; $email_exp = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i"; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[a-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); header('location: thankyou.html.php?op=Thank You'); } ?> Many thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.