PHP email problems
Posted: Wed Jun 13, 2007 7:50 pm
Hi guys,
Here are the php script:
Now, when the user fill the form, its automatically send to my email. If the user forgot to fill the name, email address and comment on the form, they have to repeat and fill the form again. With my script, when the user forgot to fill the name, email and comment, its automatically send to my email but I don't want this.
Can you give me what is the code for this please? That's be great!
Thanks alots.
Here are the php script:
Code: Select all
<?php
//Headers---
$name = $_POST['name'];
$message = $_POST['comments'];
$from = $_POST['email'];
$mail_sent = $_POST['submit'];
//send the email---
//define the receiver of the email
$to = 'wade@austasiagroup.com'.",";
$to .= '';
//define the subject of the email
$subject = 'Kiri Park Enquiry';
//define the message in the email
$body = "The following enquiry was submitted via the Kiri Park website on ".date('l, d M Y H:i:s') . "\n\nName: ". $name ."\n\nEmail: ". $from ."\n\nComments: ". $message;
//mail sent.
$mail_sent = mail( $to, $subject, $body, "From: $from" );
/*Simple form validation check to see if an email and message were entered*/
//if no name entered, no message entered and no email entered print an error
if (empty($message) && empty($from) && empty($name)){
echo "<div class=\"bodytext\">No name, email address and comment was entered. Please enter your name, email address and a comment.</div>";
}
//if no message entered and no email entered print an error
elseif (empty($message) && empty($from)){
echo "<div class=\"bodytext\">No email address and comment was entered. Please enter your email address and a comment.</div>";
}
//if no name entered and no message entered print an error
elseif (empty($name) && empty($message)){
echo "<div class=\"bodytext\">No name and comment was entered. Please enter your name and a comment.</div>";
}
//if no name entered and no email address entered print an error
elseif (empty($name) && empty($from)){
echo "<div class=\"bodytext\">No name and email address was entered. Please enter your name and email address.</div>";
}
//if no message entered send print an error
elseif (empty($message)){
echo "<div class=\"bodytext\">No comment was entered. Please enter a comment.</div>";
}
//if no email entered send print an error
elseif (empty($from)){
echo "<div class=\"bodytext\">No email address was entered. Please enter your email address.</div>";
}
//if no name entered send print an error
elseif (empty($name)){
echo "<div class=\"bodytext\">No name was entered. Please enter your name.</div>";
}
//Thank the user by name if they entered a name
elseif (!empty($name)) {
echo "<div class=\"bodytext\">Thank you, $name. Your mail was sent successfully.</div>";
}
?>Can you give me what is the code for this please? That's be great!
Thanks alots.