Jump to content

Archived

This topic is now archived and is closed to further replies.

phobia

Help: Unique PHP Email Form

Recommended Posts

Can anyone help and give a sample working php code like the one below?

One input form that accepts email addresses then validates the email if it's in the correct format.

After the user clicks the submit button it will send them an html page to their email address.

Then automatically goes back to the original page where they filled the form but now the form must not be visible anymore and must be replaced with a "Thank you, we will contact you shortly" on it's position to the page.

Any PHP guru here can help me with my problem?

Thanks a lot!

Share this post


Link to post
Share on other sites
This is the only code I have. I know I'm missing some things.

The HTML form:
<form action="email_submit.php" method="post">
<div id="form">
<input name="email" type="text" id="email_field" />
</div>
<div id="submit"><input name="submit" type="submit" id="email_send" value="Submit" /></div>
</form>

The PHP code:
<?php

$to_address=$_POST['email'];
$from_address="email@email.com";
$reply_address="email@email.com";

$notify_address="email@email.com"; // $from_address;
$html_message=file_get_contents('email_send.html');
$subject="Thank you for contacting us.";

//add From: header
$headers = "From: ".$from_address."\r\n";
$headers .= "Reply-To: ".$reply_address."\r\n";
//specify MIME version 1.0
$headers .= "MIME-Version: 1.0\r\n";

//unique boundary
$boundary = uniqid("HTMLDEMO");

//tell e-mail client this e-mail contains//alternate versions
$headers .= "Content-Type: multipart/alternative" .
   "; boundary = $boundary\r\n\r\n";

//message to people with clients who don't
//understand MIME
$headers .= "This is a MIME encoded message.\r\n\r\n";

//plain text version of message
$headers .= "--$boundary\r\n" .
   "Content-Type: text/plain; charset=ISO-8859-1\r\n" .
   "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("This is the plain text version!"));

//HTML version of message
$headers .= "--$boundary\r\n" .
   "Content-Type: text/html; charset=ISO-8859-1\r\n" .
   "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($html_message));


$notify_message="NOTICE: ".$to_address." has requested contact. \n\n A request for more information from $to_address has come through the site at ".date('l dS \of F Y h:i:s A');

//send message
mail($to_address, $subject, "", $headers);
mail($notify_address, "Form", $notify_message);

$email_status="OK";

include(".$_POST[sendback_page]");

?>

Share this post


Link to post
Share on other sites

×

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.