Topic: First-time form from scratch - probably doing a LOT wrong
<?php
if (isset($_POST['submit'])) {
$to = "someone@somewhere.com";
$subject = "Website Order";
$name_field = $_POST['name'];
$phone_field = $_POST['phone'];
$mobile_field = $_POST['mobile'];
$email_field = $_POST['email'];
$address = $_POST['address'];
$postcode_field = $_POST['postcode'];
foreach ($_POST['regionalSeries'] as $value) {
$radio_msg .= "Regional Series: $value";
}
if (isset($_POST[‘personalised’])) {
foreach ($_POST['personalised'] as $value) {
$radio_msg2 .= "Regional Series: $value\n";
}
}
foreach ($_POST['locations'] as $value) {
$check_msg .= "Locations: $value\n";
}
//foreach ($_POST['personalised'] as $value) {
// $radio_msg2 .= "Personalised: $value";
// }
$description = $_POST['description'];
$instructions = $_POST['instructions'];
$body = "\nFrom: $name_field\nTelephone: $phone_field\nCellphone: $mobile_field\nE-Mail: $email_field\n\nDelivery Address: $address\nPostcode: $postcode_field\n\n$radio_msg\n$check_msg\n\n$radio_msg2\nPersonalised: $description\nSpecial Instructions: $instructions";
//echo "Data has been submitted to $to!";
header("Location: thank-you.html");
mail($to, $subject, $body);
} else {
echo "blarg!";
}
?>What I'm trying to do here is (well, probably obvious) - just not to me.
Any advice on how to make this better?
Error correction. Hmmm... Security? What's that?
Basically, it works (well, the $radio_msg2 doesn't display in the email) so I guess it doesn't really.
I'm just looking for some pointers, to improve the way the form data is handled.
If this isn't the right place to post such a thing - I apologise in advance.
Thanks for looking.
Jas
