PHP Form Help (1 Viewer)

swingkid

New Member
Joined
Jan 8, 2001
Messages
2,071
Location
where i live
Website
www.wfmu.org
Hey

I need some help with writing a php script for a form that has just 5 fields, with the content being sent to just 1 email address.

It should be really simple but i'm only looking at php for the first time really.

any help appreciated.
thanks.
 
Here you go :

<?php

// If the form was submitted
if (isset($_POST['submit']))
{
// Send a mail with the values from the form fields
send_mail(
$_POST['f1'],
$_POST['f2'],
$_POST['f3'],
$_POST['f4'],
$_POST['f5']);

// Exit the script
exit;
}

// A function to send an email containing the values of the form fields
function send_mail($v1, $v2, $v3, $v4, $v5)
{
// Who you are sending the email to
$to = '[email protected]';

// The subject of the email
$subject = 'The form values';

// The message body of the email
$message = 'Field 1 : ' . $v1 . "\r\n" .
'Field 2 : ' . $v2 . "\r\n" .
'Field 3 : ' . $v3 . "\r\n" .
'Field 4 : ' . $v4 . "\r\n" .
'Field 5 : ' . $v5 . "\r\n";

// Additional headers such as the return address
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

// Send the email
mail($to, $subject, $message, $headers);
}

?>
<html>
<head>
<title>Sample form</title>
</head>
<body>
<form name="form" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div><label>Field 1:</label><input type="text" name="f1"/></div>
<div><label>Field 2:</label><input type="text" name="f2"/></div>
<div><label>Field 3:</label><input type="text" name="f3"/></div>
<div><label>Field 4:</label><input type="text" name="f4"/></div>
<div><label>Field 5:</label><input type="text" name="f5"/></div>
<div><input type="submit" name="submit" value="Submit"/></div>
</form>
</body>
</html>
 
Sorry about the formatting there. Neither of the code or php tags are working for me in vbulletin when I post that bit of code.
 

Users who are viewing this thread

Activity
So far there's no one here
Old Thread: Hello . There have been no replies in this thread for 365 days.
Content in this thread may no longer be relevant.
Perhaps it would be better to start a new thread instead.

21 Day Calendar

Landless: 'Lúireach' Album Launch (Glitterbeat Records)
The Unitarian Church, Stephen's Green
Dublin Unitarian Church, 112 St Stephen's Green, Dublin, D02 YP23, Ireland

Support thumped.com

Support thumped.com and upgrade your account

Upgrade your account now to disable all ads...

Upgrade now

Latest threads

Latest Activity

Loading…
Back
Top