...

View Full Version : Emails from a form using PHP [New to PHP]



sjwatsi
01-03-2008, 11:49 AM
Hi all.

I'm competant with HTML and such and have decided to pick up a little PHP for my future studies etc.. I have some understanding of PHP, but nothing that can be properly applied.

I was thinking that I would try producing a webform to send me emails of whatever has been entered. The idea sounds easy enough to me, but I have a couple of questions to someone who knows PHP (and related skills).

First, how easy is this to implement? I'm not quite a beginner, but might as well be sometimes. :p

Second, what do I need to get this working?

Many thanks if you do reply. If you need more info of what I am trying to do or what I can do let me know.

Cheers
sjwatsi

twomt
01-03-2008, 12:28 PM
Assuming you know how to get the form data over to the php script and you are sending 3 fields : from, subject and body you could do something like this



<?php
$from = $_POST['from'];
$subj = $_POST['subject'];
$body = $_POST['body'];

mail( 'your_email@mail.com', $subj, $body, 'From: $from' );

?>


Not tried it, but I think that should work.

kbluhm
01-03-2008, 01:22 PM
You'll need to use double-quotes to parse the $from variable:


<?php
$from = $_POST['from'];
$subj = $_POST['subject'];
$body = $_POST['body'];

mail( 'your_email@mail.com', $subj, $body, "From: {$from}" );

?>

sjwatsi
01-04-2008, 11:18 AM
Many thanks to both you guys.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum