Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP mail form for website - ability to email sender

Posted on 2009-04-15
2
Medium Priority
?
433 Views
Last Modified: 2013-11-10
Attached is the code for a PHP mail form that I am currently running. What I want to do I believe is pretty simple I just can't figure it out. I currently have an email address that these forms are sent to. I have a spot in the form for the person submitting the work order to type in their address. This address is the address that the email comes from so that we can reply to them. I want the form to pull that address and send it there as well. So basically I want the form sent to the address in the mailto and whatever is typed into $email.
<?
 
$mailto = 'email@email.com' ;
$subject = "Workorder Request - Wyandotte" ;
$formurl = "http://www.websiteform.com" ;
$errorurl = "http://www.websiteform.com/erremail.html" ;
$thankyouurl = "http://www.websiteform.com/tyemail.html" ;
$uself = 0;
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$username = $_POST['username'] ;
$department = $_POST['department'] ;
$problem = $_POST['problem'] ;
$priority = $_POST['priority'] ;
$reboot = $_POST['reboot'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
	header( "Location: $formurl" );
	exit ;
}
if (empty($name) || empty($email) || empty($username) || empty($comments)) {
   header( "Location: $errorurl" );
   exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
	header( "Location: $errorurl" );
	exit ;
}
if (get_magic_quotes_gpc()) {
	$comments = stripslashes( $comments );
}
$messageproper =
	"Name of sender: $name\n\n" .
	"Email of sender: $email\n\n" .
	"Name of user with problem: $username\n\n" .
	"Department: $department\n\n" .
	"Problem: $problem\n\n" .
	"Priority Level: $priority\n\n" .
	"Has the user rebooted their computer?: $reboot\n\n" .
	"------------------------- PROBLEMS -------------------------\n\n" .
	$comments .
	"\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper,
	"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.07" );
header( "Location: $thankyouurl" );
exit ;
?>

Open in new window

0
Comment
Question by:Wyandotte
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
Chris Harte earned 2000 total points
ID: 24148377
Add your recipients to a variable $to, seperated by a comma, and use that in your send to field.

 
$to = $mailto.','. $email;        
mail($to, $subject, $messageproper,

Open in new window

0
 

Author Comment

by:Wyandotte
ID: 24148653
That worked great. Thanks.
0

Featured Post

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question