Hi I have created a comments form in
php, which is located at
www.galaxywindows.co.uk/comments.php
However when i click submit the message isn't sent to my email, Does anyone know why this might be. Below is the code.
Part 1 - Comments.php
<!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>Untitled Document</title>
</head>
<body>
<?
php
if(isset($_GET['posted'])) {
$to = 'jonbenitos@gmail.com'; //Email address to send it to
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$message = $_POST['message'];
//This is the body of the email. You can modify it...
$body = 'Name: ' . $fname . ' ' . $lname . ' Email: ' . $email . ' Message: ' . $message;
//Send the message...
if(mail($to, 'Site Message', $body)) {
die('Success!');
} else {
die('Failure!');
}
}
?>
<form method="Post" action="
http://www.galaxywindows.co.uk/comments.php?posted=yes">
<table>
<tr>
<td><label for="fname">First Name:</label></td>
<td><input type="text" name="fname" /></td>
</tr>
<tr>
<td><label for="lname">Last Name:</label></td>
<td><input type="text" name="lname" /></td>
</tr>
<tr>
<td><label for="email">E-Mail:</label></td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td><label for"message">Message:</label></td>
<td><textarea name="message"></textarea></td>
</td>
<tr>
<td><input type="submit" /></td>
</tr>
</table>
</form>
</body>
</
html>
Part 2 - Code.php
<?
php
if(isset($_GET['posted'])) {
$to = 'jonbenitos@gmail.com';
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$message = $_POST['message'];
//This is the body of the email. You can modify it...
$body = 'Name: ' . $fname . ' ' . $lname . ' Email: ' . $email . ' Message: ' . $message;
//Send the message...
if(mail($to, 'Site Message', $body)) {
die('Success!');
} else {
die('Failure!');
}
}
?>