Jump to content

Recommended Posts

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
  

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.