Jump to content


Photo

email to sender as well as myself (code inside)


  • Please log in to reply
4 replies to this topic

#1 theunavailablename

theunavailablename
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 03 September 2006 - 04:50 PM

I am trying to get the email to be sent to the person sending the email, not just myself. i put $email in for the contact but its not working and i dont know what else might do it.

if $email isnt working what is the code that could do it, if im even puting it in the right spot.

thanks

-S

*note* this is just the top part of the php code.

/* ========================= Begin Configuration ============================ */
	define("kContactEmail","name@website.com, $email");
  /* ========================= End Configuration ============================== */

  // init variables
	$error_msg = 'The following fields were left empty or contain invalid information:<ul>';
	$error = false;

	// determine is the form was submitted
	$submit = $_POST['submit'];
	if (empty($submit)) 
		$form_submitted = false;
	else
	  $form_submitted = true;

  if ($form_submitted) {
	  // read out data
	  $name = $_POST['name'];
		$company = $_POST['company'];
		$email = $_POST['email'];
		$subject = $_POST['subject'];
		$game1 = $_POST['game1'];
		$game2 = $_POST['game2'];
		$game3 = $_POST['game3'];
		$game4 = $_POST['game4'];
		$game5 = $_POST['game5'];
		$game6 = $_POST['game6'];
		$game7 = $_POST['game7'];
		$game8 = $_POST['game8'];
		$game9 = $_POST['game9'];
		$game10 = $_POST['game10'];
		$game11 = $_POST['game11'];
		$game12 = $_POST['game12'];
		$game13 = $_POST['game13'];
		$game14 = $_POST['game14'];
		$game15 = $_POST['game15'];
		$game16 = $_POST['game16'];
		$message = $_POST['message'];
		
		
		// verify required data
		if(!$name) { $error_msg .= "<li>Full Name</li>"; $error = true; }
		if(!$email) { $error_msg .= "<li>E-mail Address</li>"; $error = true; }
		if(!$subject) { $error_msg .= "<li>Subject</li>"; $error = true; }
		if(!$message) { $error_msg .= "<li>Message</li>"; $error = false; }
		if($email) { if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){ $error_msg .= "<li>E-mail Address</li>"; $error = true; }}
		$error_msg .= "</ul>";
		
		// email message if no errors occurred
		if (!$error) {
      // prepare message
			$msg  = "Full Name: \t $name \n";
			$msg .= "E-mail Address: \t $email \n";
			$msg .= "Game1: \t $game1 \n";
			$msg .= "Game2: \t $game2 \n";
			$msg .= "Game3: \t $game3 \n";
			$msg .= "Game4: \t $game4 \n";
			$msg .= "Game5: \t $game5 \n";
			$msg .= "Game6: \t $game6 \n";
			$msg .= "Game7: \t $game7 \n";
			$msg .= "Game8: \t $game8 \n";
			$msg .= "Game9: \t $game9 \n";
			$msg .= "Game10: \t $game10 \n";
			$msg .= "Game11: \t $game11 \n";
			$msg .= "Game12: \t $game12 \n";
			$msg .= "Game13: \t $game13 \n";
			$msg .= "Game14: \t $game14 \n";
			$msg .= "Game15: \t $game15 \n";
			$msg .= "Game16: \t $game16 \n";																											
			$msg .= "Message: \n---\n $message \n---\n";

			// prepare message header
			$mailheaders  = "MIME-Version: 1.0\r\n";
			$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
			$mailheaders .= "From: $name <$email>\r\n";
			$mailheaders .= "Reply-To: $name <$email>\r\n"; 

		  // send out email
			mail(kContactEmail, $subject ,stripslashes($msg), $mailheaders);
		}
	} 
?>
<html>
<head>

<title>Contact Us</title>
<style type="text/css">
<!--
	td.form         { color: #efefef; font-family: "Verdana","Arial"; font-size: 11; }
	td.main         { color: #efefef; font-family: "Verdana","Arial"; font-size: 12; }
	font.form_check {	color: ff0000; }
	input           { font-family: "Verdana","Arial"; color:#606060; font-size: 11px; }
	textarea        { font-family: "Verdana","Arial"; color:#606060; font-size: 11px; }
	div#form_box    { margin: 2px; width: 400px; border: 0px; border-style: solid; border-color: #C37D3F; background: #000000; padding: 5px; }
	h1              { font-size:16; color: #606060; }
-->
</style>
</head>
<body>
<!-- box around the page -->
<div id="form_box"> 
<table border="0" width="400" cellpadding="1" cellspacing="0" height="400">
	<tr>
		<td class="main" valign="top">
			<!-- page heading-->
			<center><h1></h1></center>
			<?php
				// email was successfully send
				if (($form_submitted) && (!$error)) {
			?>
			<!-- display submitted data -->
			Thank you for your feedback, <?php echo $name; ?>.
			This is the information you submitted:<br><br><?php echo nl2br(stripslashes($msg)); ?>
			<?php	
				}
				// display contact form
				else {
					// display error message
					if ($error) {	
						echo "<font class='form_check'>" . $error_msg . "</font>\n";
					} 
			?>


#2 AdRock

AdRock
  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 03 September 2006 - 08:23 PM

Have a look here at this code for their contact form.

There is an option which you can modify to send a copy of the email to the sender

http://www.ibdhost.com/contact/
If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#3 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 03 September 2006 - 11:54 PM

Add this under the mail headers

$mailheaders .= 'Bcc: you@domain.tld' . "\r\n";

Replacing you@domain.tld with the email address you want the email BBC to
Tell me the problem, I will try tell you the solution

#4 theunavailablename

theunavailablename
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 04 September 2006 - 12:07 AM

Add this under the mail headers

$mailheaders .= 'Bcc: you@domain.tld' . "\r\n";

Replacing you@domain.tld with the email address you want the email BBC to


that works if i want it to just got to one other person other than myself all the time.

but i want it to go to whoever types in their email in the email section. so they get a copy of what they just emailed to me.

#5 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 04 September 2006 - 12:10 AM

ok
say there email address is stored in variable $email;
so
$mailheader .= 'Bcc: '.$email.' "\r\n";

Tell me the problem, I will try tell you the solution




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users