Jump to content

[SOLVED] How to create a "email me this info" page


robin339

Recommended Posts

Hey guys,

 

How do i make a "email me this info" page from a order confirmation page? Basically someone enters some info in a form, then on submission is comes to my email. After submission, i want to have a text area where they can enter an email address to have the info emailed to them if they wish.

 

You can see the page here, you have to enter info first, the email nbox on the second page (process.php) is non fuctional. Click here

Thanks :)

this took ages to work out but here you go you can send an email to client

and ur  company or just to company.

 

<?php
$mail_date = date('l dS \of F Y h:i:s A');
$email_url = $_SERVER['PHP_SELF'];
$email_ip = $_SERVER['REMOTE_ADDR'];
$x=array("users_email@what_ever.com","company@what_ever.com");
$a=$x[0];
$c=$x[1];
foreach($x as $key => $val){
if($b=="yes"){
$val="$a,$c";
$val=str_replace("yes","",$val);
}
if($b=="no"){
$val=$c;
}
$to = $val;
}
$subject2 = "Email Subject";
$email = "The following page, $email_url , was accessed.
IP: $email_ip  
Date: $mail_date
This is an automated email! DO NOT REPLY!";
$from = "[email protected]";
$headers1 = "MIME-Version: 1.0\r\n";
$headers1 .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers1 .= "To: ".$to."\r\n";
$headers1 .= "From: ".$from."\r\n";
$headers1 .= "Reply-To: ".$from."\r\n";
mail($to, $subject2, $email, $headers);
echo" <form method='POST' action=''>
<select name='b'>
<option value='yes'>yes</option>
<option value='no'>no</option>
</select>
<input type='submit' name='submit' value='send email'>
</form>";
?>

You don't have to hard code the email address in the mail function.

 

 

$to=$_POST['email_address'];

$subject="some subject here... can come from a $_POST[] field too.";

$body="This is the body of the email.... it too can come from a $_POST[] field";

$header='this is where you put headers like content type, from, cc, bcc, etc";

 

 

mail($to, $subject, $body, $header);

create a form field called email

 

<input name="email" type="text" id="email">

 

 

Then on the page that is going to process the form, add this.

 

<?php
$to=$_POST['email']; // this line right here accepts the input box and sets to a variable called $to.


$subject="some subject here... can come from a $_POST[] field too.";
$body="This is the body of the email.... it too can come from a $_POST[] field";
$header='this is where you put headers like content type, from, cc, bcc, etc";

mail($to, $subject, $body, $header);
?>

Archived

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

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