我正在编写一个个人网站,但我的联系人有问题。如果您能帮我找出问题所在,我将不胜感激。
该网站的链接是 www.tiryakicreative.com,php 表单的代码如下:
<div id="form">
<form id="ajax-contact-form" action="contact_form/send_form_email.php…
<fieldset class="info_fieldset">
<div id="note"></div>
<div id="fields">
<label>Name</label>
<input class="textbox" type="text" name="name" value="" />
<label>E-Mail</label><input class="textbox" type="text" name="email" value="" />
<label>Subject</label>
<input class="textbox" type="text" name="subject" value="" />
<label>Message</label>
<textarea class="textbox2" name="message" rows="5" cols="25"></textarea>
<label> </label><input class="button" type="image" src="send2.gif" id="submit" Value="Send Message" />
</div>
</fieldset>
</form>
</div>
</div>
这是给定 html 代码的 php 代码:
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "ian_tiryaki@hotmail.com";
$email_subject = "New Email from Website";
function died($error) {
// ERROR CODE GOES HERE
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.";
echo $error."";
echo "Please go back and fix these errors.";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['subject']) ||
!isset($_POST['message'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['subject']; // not required
$comments = $_POST['message']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Z…
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The Name you entered does not appear to be valid.';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The subject you entered does not appear to be valid.';
}
if(strlen($comments) < 2) {
$error_message .= 'The message you entered do not appear to be valid.';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:",…
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Subject: ".clean_string($telephone)."\n";
$email_message .= "Message: ".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 success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>