Jump to content

Recommended Posts

I have a PHP code in a contact form.  I want this form to be emailed to customers when someone fills it in.  I can change the recipient and rename the file, that is no problem.  But I need the email to look nice.  I want a header, http://www.vacation-vallarta.com/images/logo.png on the top, I also want the info to be seperated by line item.

 

Example email

 

Arrival:  8/12/2013

 

Depar: 8/11/2013

 

It is simple but I just can not figure it out.  I want the beginning of the email to state "You have a inquiry from "$name" from Vacation-Vallarta.  Then start all the contact information.  I want it to be nice for clients instead of a mess.  If you can help me out, please email sales@vacation-vallarta.com and I can pay you through papayl

 

<html>

<head>

<title>Thanks For Contacting Us</title>

</head><?php

 

  $recipient = 'sales@vacation-vallarta.com';

  $name1 = $_POST['name1'];

  $email1 = $_POST['email1'];

  $phonenumber = $_POST['phonenumber'];

  $subject1 = $_POST['subject1'];

  $questions = $_POST['questions'];

  $arrival = $_POST['arrival'];

  $depart = $_POST['depart'];

  $messages = array();

if (!preg_match("/^[\w\+\-.~]+\@[\-\w\.\!]+$/", $email1)) {

$messages[] = "Please provide a valid email address";

}

if (!preg_match("/^[\w\ \+\-\'\"]+$/", $name1)) {

$messages[] = "The name field must contain only alphabetical characters, numbers, spaces, and reasonable punctuation." ;

}

$subject1 = preg_replace('/\s+/', ' ', $subject1);

if (preg_match('/^\s*$/', $subject1)) {

$messages[] = "Please specify the property you are requesting the availability for.";

}

$arrival = $_POST['arrival'];

if (preg_match('/^\s*$/', $arrival)) {

$messages[] = "Plese enter the day you arrive.";

}

$depart = $_POST['depart'];

if (preg_match('/^\s*$/', $depart)) {

$messages[] = "Plese enter the day you depart.";

}

  if (count($messages)) {

    foreach ($messages as $message) {

      echo("<p>$message</p>\n");

    }

    echo("<p>Click the back button and correct the problems. " .

      "Then click Send Your Message again.</p>");

  } else {

mail($recipient, $subject1, $depart, $arrival, $questions, $phonenumber,

  "From: $name <$email1>\r\n" .

      "Reply-To: $name <$email1>\r\n");

  echo header ("Location: thankyou.html");

 

  }

?>

</body>

</html>

 

 

Link to comment
https://forums.phpfreaks.com/topic/267080-looking-for-php-contact-form-help/
Share on other sites

I would highly suggest checking out PHPMailer.

 

$mail             = new PHPMailer(); // defaults to using php "mail()"

$body             = file_get_contents('contents.html');
$body             = preg_replace('/[\]/i','',$body);

$mail->SetFrom('name@yourdomain.com', 'First Last');

$mail->AddReplyTo("name@yourdomain.com","First Last");

$address = "whoto@otherdomain.com";
$mail->AddAddress($address, "John Doe");

$mail->Subject    = "PHPMailer Test Subject via mail(), basic";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$mail->AddAttachment("images/phpmailer.gif");      // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

The problem is I do not know how to do it.  I wish I did.  If you know, I will compensate you accordingly.

 

Real quick, I'm going to show you something to save your butt, then I'll try to explain how to do this.

Forum Rules

----

12. All request for code to be written for you should be posted under the freelance section. No exceptions.

 

What is it exactly is it that you need help with?

If you're looking to get code written for you, then you'll have to go to the Freelance Section.

If you're looking for assistance with code that you're writing, you'll have to let us know what you need help with.

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.