Page 1 of 1

Need to create submitter email in PHP code dreamweaver

Posted: Thu Nov 18, 2010 11:37 pm
by lross30
First - I am not very technical. Have a website for my business and created a form in Dreamweaver CS5 using PHP to collect data. I want to send a confirmation e-mail to the submitter and do not know how to do this. I found the PHP code for the e-mail response online - can't find any thing to help me take my existing code and add additional e-mail back to submitter. Code that I am using is posted below. Any assistance or advice would be greatly appreciated!

Code: Select all

<title>sendresults3</title>
<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'xxxx'; 

// Your email address. This is where the form information will be sent. 
$emailadd = 'xxxx@mail.com'; 

// Where to redirect after form is processed. 
$url = 'http://compant.com" 

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
/*Gathering Data Variables*/


// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n"; 
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

Re: Need to create submitter email in PHP code dreamweaver

Posted: Fri Nov 19, 2010 3:09 am
by Neilos
Hello lross30,

What do you mean by;
can't find any thing to help me take my existing code and add additional e-mail back to submitter
Do you mean that you want to send a confirmation email back to the submitter which contains all of their form inputs?

It's difficult to tell what it is you are trying to achieve from your code. Try explaining the whole problem so we can give you the best advice.

But... essentially you have it.

I am assuming that you are trying to do what I thought. Well if you have a form of the sort;

Code: Select all

<form name="inputs" action="inputs.php" method="post">
<input type="text" name="email" />
<input type="text" name="name" />
<input type="text" name="otherStuff" />
<input type="submit" value="Submit" />
Then in the file inputs.php you could have something like;

Code: Select all

<?php

	$email = $_POST['email'];
	$name = $_POST['name'];
	$otherStuff = $_POST['otherStuff'];

echo "A confirmation email has been sent to $_POST[email]";

//Send confirmation Email
$to = $email;
$subject = "somewebsite.com Registration";
$message = "Thank you $name for your input!\r\rYou, or someone using your email address, has completed a form at somewebsite.com.\rYou have sent the information:\r\remail: $email\rName: $name\rOther Stuff: $otherStuff.\r\r Thanks again!";
				
$headers = 'From: noreply@somewebsite.com' . "\r\n" .
				
'Reply-To: noreply@somewebsite.com' . "\r\n" .
				
'X-Mailer: PHP/' . phpversion();
				
mail($to, $subject, $message, $headers);

?>
By the way I haven't checked that code so there is probably an error or two (I just edited one error out of it lol) but you get the jist! :D

Re: Need to create submitter email in PHP code dreamweaver

Posted: Fri Nov 19, 2010 4:17 am
by Luke
Please remember to wrap your PHP (and other code) snippets in the appropriate bbcode tags. For php, that would be

Code: Select all

. I have adjusted your post to reflect how we'd like to see code posted in the future. Thanks! :)

Re: Need to create submitter email in PHP code dreamweaver

Posted: Mon Nov 22, 2010 4:42 pm
by lross30
Thanks! I thought I had posted a reply last week buy maybe it hit "save" instead of "submit". As stated before - I am not very technical but trying to get our company website to work. I found code online to have a web form submit results to an email address to collect data. We now want to add an additional e-mail that will send an e-mail to the submitter with confirmation e-mail and information about a trial. Since I am not technical, I literally found code online for my first need (e-mail to me with results of the form) and it worked. This is what I had posted. I was hoping that I could just add to that code so I can also have an e-mail sent to the submitter.

I haven't had the chance to try what you posted, but will later today. I appreciate your feedback and the details of forum protocol! :) :D