Hi,
I’ve been trying to make a simple contact form pretty much all day. I think it will probably end up being a really straightforward answer for anyone with PHP experience (I have none at all, trying to use code from a book). I am trying to achieve a simple form to collect – name, email, phone number, website, a message and to show me which services they’re interested in. Sorry my code is so messy – I’ve been going round forums trying different things and I think I’ve made it worse now! (There’s CSS with this so if you recreate might look a bit dodgy).
Currently, it does not email me the message or show which services that they have selected.
HTML:
<form action=”send_form.php” method=”POST”>
<div class=”left”><p>
<label for=”name”>Name:</label><br />
<input type=”text” name=”name” id=”name” />
<p>
<label for=”phone”>Phone:</label><br />
<input type=”text” name=”phone” id=”phone” /></p></div>
<p><br />
<label for=”email”>Email:</label>
<br />
<input type=”text” name=”email” id=”email” /></p>
<p>
<label for=”website”>Website:</label>
<br />
<input type=”text” name=”website” id=”website” /></p></div>
<div class=”bottom”>
<p>Which services do you require?</p>
<label for=”webdesign”>web design</label>
<input name=”service[]” input type=”checkbox” value=”web design”/>
<label for=”cat”>cat</label><input name=”service[]” input type=”checkbox” value=”cat” />
<br />
<label for=”hamsters”>hamsters</label><input name=”service[]” input type=”checkbox” value=”hamsters” />
<label for=”window”>window</label><input name=”service[]” input type=”checkbox” value=”window” />
<p><br />
<label for=”message”>Message:</label></p>
<p><textarea name=”message” cols=”65″ rows=”6″ name=”message”></textarea></p>
<input name=”submit” type=”submit” value=”Submit” />
</form>
PHP:
<?php
$subject =”Enquiry from Freedom Designs”;
$message=”$message”;
$name = $_POST[‘name’];
$email = $
$phone = $_POST[‘phone’];
$website = $
foreach($_POST[‘service’] as $value)
{
$Body .= “Service: ” . trim(stripslashes($value)) . “n”;
}
$msg = “Item Selected:tn”;
foreach($
{
$msg .= “$valuen”;
}
$recipient =’
$formcontent=” From: $name:
$mailheader = “From: $email
$mailheader .= “Reply-To: $email
$mailheader .= “MIME-Version: 1.0
mail($recipient, $subject, $formcontent, $mailheader) or die(“Failure”);
echo “We’ve received your message and will reply within 24 hours.”;
?>
Would appreciate any help! Thanks ?