Jump to content

[SOLVED] Emailing form details to user


nadz

Recommended Posts

basically i have a form on my page that the users fill out. i would like all the details submitted to the form to be emailed to the user.

 

there are four fields and id like the email to look like this:

 

Your name:

Your details 1:

Your details 2:

Your details 3:

 

i have the form ready and at the moment it stores the details in a mysql database, but id like to change it to email everything to the user instead.

 

any help would be appreciated.

Link to comment
Share on other sites

Use the search function on this forum or on www.php.net and look for the mail function.

It's been talked about probably 100 times here ;)

 

Do some research and if you run into any problems, come back and we can help you through it. There are a ton of ways to e-mail things so if you're asking for someone to write it for you, there is another forum for that as well. ;)

Link to comment
Share on other sites

sorry i didnt explain myself properly, i know how to use the mail function and ive got it all set up but im having trouble displaying any of the details from the form and database. the email that the message is sent to is fetched from the database using a supplied id number to find it. for example, http://site.com/page.php?id=32 will email the message to the address of the user with id 32.

 

 



$fetch=mysql_fetch_assoc(mysql_query("SELECT `email` FROM `crush2` WHERE `id`='$id'"));
  $email = $fetch['email'];

if(mail ($email, $emailsubject, $body, "From: your site <crushreply@****.co.uk>"))
   
include("crush/done.php");

 

my problem is that it doesnt email it to the address it grabs, in fact it doesnt fetch the address. can anyone see any errors in my code.

Link to comment
Share on other sites

Are you sure $id contains a value. If it is coming from get I would suggest adding this:

 

$id = isset($_GET['id'])?$_GET['id']:0;

if ($id > 0) {
   
$fetch=mysql_fetch_assoc(mysql_query("SELECT `email` FROM `crush2` WHERE `id`='$id'"));
  $email = $fetch['email'];

if(mail ($email, $emailsubject, $body, "From: your site <crushreply@****.co.uk>"))
   
include("crush/done.php");
}else {
echo 'invalid id';
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.