Contact Form W/ Confirmation Email?

Hello,
I have been trying to make a basic form with a First Name, Last Name, Email, and Invitation Code fields. Then once the submit button has been clicked it will send me the info they entered and there email will get a “Thank you” email. The main problem with this is the template that I am using, It doesn’t want to work with random codes. I was using a very confusing Ajax / JS way to make the email send but no luck with the confirmation. So I am starting from scratch and seeing that I cant seem to find any help online about confirmations I though I would ask here. I want to keep it basic so I can easily edit the code for other forms that I may need. The template is in HTML but the index page is linked to every other HTML page using the code in the index.html file head tag for every HTML page.

Here is the template that I am using:

http://www.renklibeyaz.com/rightnow/

Thank you and any help is much appreciated.

The code is now sending the email to me perfectly. I cant set the code to get it to send the user an confirmation email yet. Here is the code so far.

Form:
[php]

First Name:
Last Name:
Email Address:
Invitation Code:
[/php]

Send.php File:
[php]<?php

$ip=$_SERVER[‘REMOTE_ADDR’];
$email_to = "[email protected]";
$email_subject = “Registration”;

$email_message .= “First Name Entered: “.$_POST[“fname”].”\n”;

$email_message .= “Last Name Entered: “.$_POST[“lname”].”\n”;

$email_message .= “Email Entered: “.$_POST[“email”].”\n”;

$email_message .= “Invitation Code: “.$_POST[“email1”].”\n”;

$email_to2 = “email”;
$email_subject2 = “Code Events | Thank You”;
$email_thankyou = “Thank you”;

//email headers

$headers = 'From: '.$_POST[“email”]."\r\n".

'Reply-To: '.$_POST[“email”]."\r\n" .

‘X-Mailer: PHP/’ . phpversion();

echo (mail($email_to, $email_subject, $email_message, $headers) ? "Sent to mywebsite. ": “failed sending to website”);

echo (mail($email_to2, $email_subject2, $email_thankyou) ? "Sent to your email. ": “failed sending to website”);

die();

header( ‘Location: #!referal.html’ ) ;

?>

[/php]

Im trying to get the second mail tag to send an email to the user.
[php] echo (mail($email_to2, $email_subject2, $email_thankyou) ? "Sent to your email. ": “failed sending to website”);[/php]

Cool website template btw, just wished my connection didn’t suck so bad so I can hear the music without it be choppy…

Anyway, just glancing over what you’re doing I can pick out a few mistakes, but I think this one is your culprit.

Change:

[php] $email_to2 = “email”;[/php]

To:
[php] $email_to2 =$_POST[“email”];[/php]

You’re going to have to add some field validation at some point, because nothing is stopping the user from putting in invalid data. But I’m sure you’ll do that after you get the email sending out correctly.

Just to add, what a load of work for nothing. The user doesn’t need a confirmation email, they know they used the contact form and the script should confirm on the page. Why waste precious bandwidth sending pointless emails out?

And also, forms have no place in tables.

Sorry, it’s early, I didn’t sleep well and I’ve not had my caffeine fix yet. Grumpy!

Thanks guys, I figured out how to get the email to send to the user. Now I’m trying to add the verification.

Sponsor our Newsletter | Privacy Policy | Terms of Service