Log in

View Full Version : Sending email confirmation



Tayfun
08-11-2009, 03:59 PM
Hi

I have a fill-out form on a html page that runs by a php script.
On the html page I have 2 checkboxes under the fill-out form;
1. send a copy of this message to my address
2. Newsletter subscription

When the first one is checked I would need a message to be sent to the sender with a subject: "Copy of your sent contact message"

Is it possible to ad something into this script.

Would appreciate your help, thanks!

Code of the php script


<?
$subject="from ".$_GET['Name'];
$headers= "From: ".$_GET['e-mail']."\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
mail("my.mail@email.com", $subject ="Contact message", "
<html>
<head>
<title>Contact message</title>
</head>
<body>

<br>
".$_GET['Name']."
".$_GET['Surrname']."
<br>
".$_GET['Address']."
<br>
".$_GET['Post.Nr']."
".$_GET['City']."
<br>
".$_GET['Telephone']."
<br>
".$_GET['e-mail']."
<br>
<br>
".$_GET['Newsletter_confirmation']."
<br>
<br>
".$_GET['Message']."
</body>
</html>" , $headers);
?>
<script language="JavaScript" type="text/JavaScript">
<!--
window.location.href = "http://www.feltne.com/oddano_s.htm";
//-->
</script>

JShor
08-11-2009, 09:07 PM
<?php

if(isset($_GET['sendMail'])) {

$subject="from ".$_GET['Name'];
$headers= "From: ".$_GET['e-mail']."\n";
$params.='Content-type: text/html; charset=iso-8859-1';
mail("my.mail@email.com", "Contact message", "
<html>
<head>
<title>Contact message</title>
</head>
<body>

<br>
".$_GET['Name']."
".$_GET['Surrname']."
<br>
".$_GET['Address']."
<br>
".$_GET['Post.Nr']."
".$_GET['City']."
<br>
".$_GET['Telephone']."
<br>
".$_GET['e-mail']."
<br>
<br>
".$_GET['Newsletter_confirmation']."
<br>
<br>
".$_GET['Message']."
</body>
</html>" , $headers);
?>
<script language="JavaScript" type="text/JavaScript">
<!--
window.location.href = "http://www.feltne.com/oddano_s.htm";
//-->
</script>
", $headers, $params);

}

?>
<html>
<head>
</head>
<body>
<input type="checkbox" id="conf">
<label for="conf">Send an email confirmation</label>
</body>
</html>


HTH:)

Tayfun
08-12-2009, 07:48 AM
Hi, thanks for your help.

It gives me an error in the last line

Parse error: syntax error, unexpected '<' in /home/feltne/public_html/contact.php on line 46

JShor
08-12-2009, 02:12 PM
<?php

if(isset($_GET['sendMail'])) {

$subject="from ".$_GET['Name'];
$headers= "From: ".$_GET['e-mail']."\n";
$params.='Content-type: text/html; charset=iso-8859-1';
mail("my.mail@email.com", "Contact message", "
<html>
<head>
<title>Contact message</title>
</head>
<body>

<br>
".$_GET['Name']."
".$_GET['Surrname']."
<br>
".$_GET['Address']."
<br>
".$_GET['Post.Nr']."
".$_GET['City']."
<br>
".$_GET['Telephone']."
<br>
".$_GET['e-mail']."
<br>
<br>
".$_GET['Newsletter_confirmation']."
<br>
<br>
".$_GET['Message']."
</body>
</html>" , $headers, $params);

}

?>
<html>
<head>
<script type="text/javascript">
<!--
function pstPg() {
location.href='<?php echo $_SERVER['PHP_SELF']."?sendMail=True"; ?>';
}
//-->
</script>
</head>
<body>
<input type="checkbox" id="conf" onclick="pstPg()">
<label for="conf">Send an email confirmation</label>
</body>
</html>

Tayfun
08-12-2009, 08:37 PM
JShor thanks, was not quite the way I wanted it, so I removed the checkbox button and just changed the code. So that I receive the data from fill-out form and the sender recieves a confirmation mail with some explenation.


<?
$subject="from ".$_GET['name'];
$headers= "From: ".$_GET['e-mail']."\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
mail("info@somemail.com", $subject ="Contact message","
<html>
<head>
<title>Contact message</title>
</head>
<body>

<br>
".$_GET['name']."
".$_GET['surrname']."
<br>
".$_GET['address']."
<br>
".$_GET['post.code']."
".$_GET['city']."
<br>
".$_GET['telephone']."
<br>
".$_GET['e-mail']."
<br>
<br>
".$_GET['checkbox1']."
<br>
<br>
".$_GET['message']."
</body>
</html>" , $headers);
?>

<?
$to = $_GET['e-mail'];
$message = "Thank you message.<br>We will try to answer you in a short time!<br><br>Someone.com";
$subject = "Message confirmation - Someone.com";
$header = "From: info@somemail.com (Someoen.com)\r\n";
$header .= "Content-Type: text/html\r\nContent-Transfer-Encoding: 8bit";
mail($to, $subject, $message, $header);
?>

<script language="JavaScript" type="text/JavaScript">
<!--
window.location.href = "http://www.feltne.com/oddano_s.htm";
//-->
</script>