This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > September 2005 > Form Processing with PHP





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Form Processing with PHP
nordine5

2005-09-13, 4:21 am

Hi I am using Dreamweaver MX 2004 to build a registration page; I would like
the users to receive an email with their information after they press the
submit button. The email would go the the email address that was entered in the
form. I am not sure what code to use or if there is anything else I need to
change in the PHP code to make it work. Would you happen to know of a tutorial
that would teach how to do this? Thanks

rilkesf

2005-09-13, 7:15 am

The PHP code you need it the mail() function. You can read about it here:

http://us2.php.net/manual/en/function.mail.php

and here is a pretty straightforward tutorial on how to utilize it:

http://tutorials.jemjabella.co.uk/php_mail.php

nordine5

2005-09-14, 4:20 am

Thanks this work in terms of sending me an email once the user click submit;
do you know how I can tweek the code to make it send an email to the
user;(perhaps using ther email entered by the user in the email field)

rilkesf

2005-09-14, 4:20 am

Look at the first link. You'll notice how it says that the mail() function
takes this form:

mail($to, $subject, $message, $headers);

The headers variable is where you can add any extra things you want (generally
things like CC, BCC, From, etc.)

In your case, you'll want to include CC and enter your own address (use the
$to variable for the user's email address). You can add additional options to
the $headers variable by appending to the variable with the construct ".="

So, in your instance, your code will look something like this:

<?php

$to= $_POST['email']; /* user's email from previous page's form (POST assumes
the form method was 'post' */
$message = '<h1>Thanks for registering</h1> ...'; // HTML or Plain text
message
$subject = 'Your email subject here'; // enter the email subject
$headers = 'CC: your@email.com'; // enter the CC header to email yourself
$headers .= ''MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// then just call the mail() function
mail($to, $subject, $message, $headers);

?>

Hope that helps


Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews