Hey guys, I've got the HTML down when it comes to building forms but I really need a form processor to send over that data to my email because I don't know much PHP.
Please let me know if you guys have any scripts to do this.
Thanks.
<?php
// The message
$message = "Line 1\nLine 2\nLine 3";
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);
// Send
mail('caffeinated@example.com', 'My Subject', $message);
?>
PhPMailer if you want something a lil more customizable than using PHP's built in mail function.
I could quickly set something up for ya if you want![]()
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>form</title>
<!--
script to validate required form fields
add/replace values inside document.contact[""]
-->
<script type="text/javascript">
function verifyRequired() {
if (document.contact["name"].value == "") {
alert("Please enter your name.");
return false;
}
if (document.contact["email"].value == "") {
alert("Please enter your email address.");
return false;
}
return true;
}
</script>
</head>
<body>
<form action="contact.php" method="post" name="contact" onsubmit="return verifyRequired();">
Name: <input name="name" type="text" /><br/>
Email: <input name="email" type="text" /><br/>
<input name="" type="submit"/>
</form>
</body>
</html>
<?php
// -------------------------------
// simple form processor
// somlor - wickedfire 2009
// -------------------------------
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ClientIP = $_SERVER['REMOTE_ADDR'];
}
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
// add new variables, requesting data from your additional form inputs here
// send email with form data
$emailSubject = "form submission";
$emailBody = "Form details:\n"
. "\n"
. "Name : $name\n"
. "Email : $email\n"
// add your additional variables here, so you receive the data in your email
. "\n"
. "IP : $ClientIP\n";
$emailTo = "myemail@whatever.com"; // email form will be sent to
$emailFrom = "myemail@whatever.com"; // email form will be sent from (doesn't matter, usually keep the same as emailTo)
$emailHeader = "From: $emailFrom\n"
. "MIME-Version: 1.0\n"
. "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
. "Content-transfer-encoding: 8bit\n";
mail($emailTo, $emailSubject, $emailBody, $emailHeader);
// redirect to thank you page
header('Location: thanks.html'); // put URL to your thank you page here
exit;
?>
Yeah, hah, that's exactly where I got the original processor code above. Nowadays I prefer to just manually tweak the code above unless I'm working with a huge form with tons of complex fields. Then I'll throw it into FormsToGo, good little program.Easier than copying, pasting and editing the above... download FormsToGo and make a few clicks.
It's not almighty but it does the job.
If you don't want to be bogged down by a ton of reading, try [sams] Teach Yourself PHP in 10 Minutes. It's $15