网站链接:Contact Me / php Form Page
下面显示的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Contact Me | MXJGTV</title>
<link rel="shortcut icon" href="favicon.ico" >
<link rel="icon" type="image/gif" href="images/favicon.gif" >
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="Jack Griffiths' Motocross & Boxing website" name="keywords" />
<meta content="Jack Griffiths' Motocross & Boxing website" name="description" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
html {
height: 100%;
width: 100%
}
a:link {
color: purple;
}
a:visited {
color: purple;
}
a:hover {
color: purple;
}
a:active {
color: purple;
}
.auto-style5 {
font-family: Arial, Helvetica, sans-serif;
font-size: medium;
color: #AAAAAA;
text-align: left;
max-width: 100%;
}
.auto-style8 {
color: #AAAAAA;
}
#sitecontainer {
width: 100% !important;
float:left !important;
min-width:600px !important;
max-width:2000px !important;
}
#footer {
float: left !important;
width: 100% !important;
display: inline;
min-width:600px !important;
max-width:2000px !important;
position: relative !important;
clear: both !important;
}
#body {
position: relative !important;
text-align: center !important;
width:100% !important;
min-width:600px !important;
max-width:2000px !important;
}
#div {
width: 100%;
min-width:600px !important;
max-width:2000px !important;
}
a:active { outline: none; }.
}
.auto-style2 {
font-family: Arial, Helvetica, sans-serif;
}
.auto-style8 {
color: #000000;
}
.auto-style9 {
color: #808080;
}
.auto-style10 {
font-family: Arial, Helvetica, sans-serif;
}
.auto-style11 {
text-decoration: none;
}
.auto-style12 {
font-size: x-large;
color: #00FF00;
}
.auto-style13 {
font-family: Arial, Helvetica, sans-serif;
color: #AAAAAA;
text-align: center;
}
</style>
</head>
<body style="margin: 0; align: center; color: #000000; background-color: #000000; width: 100%;">
<body>
<div style="width: 100%; height: 58px;">
<a href="Index.html">
<img style=" float:left; display:inline" src="images3/MXJGTV.png" width="214" height="58" alt="MXJGTVLogo" />
<a href="Photos.html">
<img style=" float:left; display:inline" src="images3/Photos.png" width="140" height="58" alt="Photos" />
<a href="Videos.html">
<img style=" float:left; display:inline" src="images3/Videos.png" width="140" height="58" alt="Videos" /></a>
<a href="Results.html">
<img style=" float:left; display:inline" src="images3/Results.png" width="140" height="58" alt="Results" />
<a href="form.php">
<img style=" float:left; display:inline" src="images3/Contact.png" width="140" height="58" alt="Contact" />
<a href="Tumblr.html">
<img style=" float:left; display:inline" src="images3/TumblrButton.png" width="140" height="58" alt="Tumblr" /></a>
{ img margin-right: 1006px; }
</div>
<img alt="border" height="1" src="images3/border.png" width="100%" />
<center>
<div id="page_content" class="auto-style5">
<strong><br />
<p>
<span class="auto-style8"><br />
</p>
</span>
<p class="auto-style13">
<strong>Have A Question? Get In Touch</strong><br />
</p>
<p>
<span class="auto-style8">
<br />
</p>
</p>
</span><center>
<!-- EMAIL FORM CODING -->
<!-- EMAIL FORM CODING -->
<!-- EMAIL FORM CODING -->
<body>
<table width="450px">
</tr>
<tr>
<td valign="top" class="auto-style11">
<label for="first_name">
<label for="comments">
<strong><span class="auto-style12">* </span>
</strong></label>First Name</label></td>
<td valign="top">
<input type="text" name="first_name" maxlength="50" size="30"><span class="auto-style10">
</span>
</td>
</tr>
<tr>
<td valign="top"" class="auto-style11">
<label for="last_name">
<label for="comments">
<strong><span class="auto-style12">* </span>
</strong></label>Last Name</label></td>
<td valign="top">
<input type="text" name="last_name" maxlength="50" size="30"><span class="auto-style10">
</span>
</td>
</tr>
<tr>
<td valign="top" class="auto-style11">
<label for="email">
<label for="comments">
<strong><span class="auto-style12">* </span>
</strong></label>Email Address</label></td>
<td valign="top">
<input type="text" name="email" maxlength="80" size="30"><span class="auto-style10">
</span>
</td>
</tr>
<tr>
<td valign="top" class="auto-style11">
<label for="telephone">
<label for="comments">
<strong><span class="auto-style12">* </span>
</strong></label>Telephone Number</label></td>
<td valign="top">
<input type="text" name="telephone" maxlength="30" size="30"><span class="auto-style10">
</span>
</td>
</tr>
<tr>
<td valign="top" class="auto-style11">
<label for="comments">
<strong><span class="auto-style12">* </span>
</strong>Comments</label></td>
<td valign="top">
<textarea name="comments" maxlength="1000" cols="35" rows="6" class="auto-style10"></textarea><span class="auto-style10">
</span>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
</td>
</tr>
</table>
</form>
<br />
MXJGTV <a class="auto-style11" href="http://www.twitter.com/mxjgtv">Twitter</a>
Page And MXJGTV <a class="auto-style11" href="http://www.Instagram.com/mxjgtv">
Instagram</a> Page<br />
</center>
<!-- EMAIL FORM CODING -->
<!-- EMAIL FORM CODING -->
<!-- EMAIL FORM CODING -->
<body>
<p></p>
<div id="body">
<?php
if(isset($_POST['email'])) {
// CHANGE THE TWO LINES BELOW
$email_to = "jackgriffiths933@yahoo.com";
$email_subject = "MXJGTV Contact Message";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted.";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
?>
</div>
</center>
</strong>
<br></br>
<br></br>
<br></br>
<br></br>
<br></br>
<br></br>
<body>
<img src="images3/border.png" width="100%" height="1" alt="border" />
</body>
</head>
<!--This is my footer below but it won't display when message is sent successfully-->
<!--This is my footer below but it won't display when message is sent successfully-->
<!--This is my footer below but it won't display when message is sent successfully-->
<div id="footer">
<div style="width: 100%; height: 58px;">
<center>
<img style=" float:left; display:inline" src="images3/MXJGTV.png" width="214" height="58" alt="MXJGTVLogo" />
<a href="Allrightsreserved.html">
<img style=" float:left; display:inline" src="images3/AllRights.png" width="366" height="58" alt="All Rights Reserved" /></a>
<a href="PrivacyPolicy.Terms.html">
<img style=" float:left; display:inline" src="images3/Terms.png" width="162" height="58" alt="Terms" /></a>
<a href="PrivacyPolicy.html">
<img style=" float:left; display:inline" src="images3/Privacy.png" width="288" height="58" alt="Privacy" /></a>
<span class="auto-style8">{ img margin-right: 890px; }
</span>
</div>
<center>
<style="text-align:center;">
<?php
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$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 = "";
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
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:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Comments: ".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);
?>
</center>
<!-- place your own success html below -->
<p></p>
<center>
<span class="auto-style13">
<strong>
<style="text-align:center;">
<center>
<br class="auto-style13" />
<span class="auto-style13"><strong>Message sent successfully. I will be in touch with you very soon.</span></strong><span class="auto-style13">
</center>
<strong>
</center>
</strong>
</strong>
</span>
<p><br />
</span>
</p>
</center>
</div>
</div>
</html>
<?php
}
die();
?>
答案 0 :(得分:0)
很明显,因为die();
行。
答案 1 :(得分:0)
您需要将所有PHP代码放在最上面并删除die()。那么HTML代码应该在底部。