Web forms, how hard can they be?
For me bloody hard going. Not so much the html & css but th ephp behind it to get the relevant info pinged back into your eMail.
This post is going to be therapy for me you habe been warned.
All i wanted to do was get the info on this form:
http://www.pauserefreshment.co.uk/coffee-machine-brochure-request.html
to ping back the data to my inbox.
I started lookin at sitepoints book “Fancy form Design” but this book does not give any useful php info regarding how your supposed to get the info pinged back to your eMail once youve designed your fancy form, a missing chapter i think!
I then took a look at O’reilly’s “Head first PHP & MySQL”. From this there was actual code you could use for a form. I used this and had some success, i could get info eMailed to me but the echo stuff i could just not change and caused lots of headaches :mad:
Ant (sitepoint member) has helped me out but my lack of understanding has caused balls ups.
So is there a tutorial or book that teaches you not only how to design forms but gives full insight into the php scripts that run behind them so people like me can start to figure it all out.
I’ve found it so hard getting a useful / idiots guide to php scripts for web forms. Can anyone point me in the right direction?
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Aliens Abducted Me - Report an Abduction</title>
</head>
<body>
<h2>Aliens Abducted Me - Report an Abduction</h2>
<?php
ini_set("sendmail_from", "user@yourdomain.com");
if (empty($_SERVER['HTTP_REFERER']) || (
(!strstr($_SERVER['HTTP_REFERER'], "http://dev.spookmedia.com/")) &&
(!strstr($_SERVER['HTTP_REFERER'], "http://pause.zippy.sdev.net/")) &&
(!strstr($_SERVER['HTTP_REFERER'], "http://www.pause.co.uk/"))&&
(!strstr($_SERVER['HTTP_REFERER'], "http://www.pauserefreshment.co.uk/"))&&
(!strstr($_SERVER['HTTP_REFERER'], "http://www.refreshments.co.uk/"))
))
{
header("HTTP/1.0 404 Not Found");
return;
}
$name = $_POST['name'] . ' ' . $_POST['secondname'];
$when_it_happened = $_POST['whenithappened'];
$how_long = $_POST['email'];
$how_many = $_POST['company'];
$alien_description = $_POST['address'];
$what_they_did = $_POST['address2'];
$fang_spotted = $_POST['postcode'];
$email = $_POST['email'];
$other = $_POST['city'];
$to = 'hello@pause.co.uk';
$subject = 'Aliens Abducted Me - Abduction Report';
$msg = "$name was abducted $when_it_happened and was gone for $how_long.\
" .
"Number of aliens: $how_many\
" .
"Address: $alien_description\
" .
"What they did: $what_they_did\
" .
"Fang spotted: $fang_spotted\
" .
"Other comments: $other";
mail($to, $subject, $msg, 'From:' . $email);
echo 'Thanks for submitting the form.<br />';
echo 'You were abducted ' . $when_it_happened;
echo ' and were gone for ' . $how_long . '<br />';
echo 'Number of aliens: ' . $how_many . '<br />';
echo 'Describe them: ' . $alien_description . '<br />';
echo 'The aliens did this: ' . $what_they_did . '<br />';
echo 'Was Fang there? ' . $fang_spotted . '<br />';
echo 'City: ' . $other . '<br />';
echo 'Your email address is ' . $email . '<br />';
?>
</body>
</html>