我有这个index.html
<form name="index" method="post" action="send_form_email.php">
<table width="450px">
<tr>
<td valign="top">
<label for="first_name"><font color="white">Nume</font></label>
</td>
<td valign="top">
<input type="text" name="first_name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top"">
<label for="last_name"><font color="white">Prenume</font></label>
</td>
<td valign="top">
<input type="text" name="last_name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="email"><font color="white">E-mail</font></label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="telephone"><font color="white">Numarul de Telefon(*)</font></label>
</td>
<td valign="top">
<input type="text" name="telephone" maxlength="30" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="comments"><font color="white">Mesajul</font></label>
</td>
<td valign="top">
<textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="Trimite">
</td>
</tr>
</table>
</form>
和send_form_email.php
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "contact@vestigedayz.com";
$email_subject = "Comentariu Site";
function died($error) {
// your error code can go here
echo "Ne pare rau dar se pare ca am intampinat o problema. ";
echo "Erorile sunt:<br /><br />";
echo $error."<br /><br />";
echo "Te rugam sa dai backspace si sa refaci corect.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('Ne pare rau dar se pare ca am intampinat o problema.');
}
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'E-mail-ul nu este corect.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'Numele tau nu este corect.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'Prenumele tau nu este corect.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'Sectiunea de mesaj nu este corecta..<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Detaliile sunt mai jos.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Nume: ".clean_string($first_name)."\n";
$email_message .= "Prenume: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telefon: ".clean_string($telephone)."\n";
$email_message .= "Mesaj: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Multumim ca ne-ai scris. Iti vom raspunde cat de curand !
<?php
}
?>
一切正常,但我没有收到任何电子邮件。为什么?一切看起来都可以,我应该添加或删除什么?我无法弄清楚。我从互联网上的教程中读到了如何创建联系表单。