doupian9490 2015-09-17 02:44
浏览 34

PHP和HTML:我做错了什么? [重复]

This question already has an answer here:

I have been looking at this for hours it seems like, but I cannot remember how to make it so my HTML and CSS shows up in the PHP output. Am I missing something? I am getting an error code on line 78 or where the code echo ""; starts. Any extra eyes would be appreciated.

<?php
if(isset($_POST['email'])) {

// CHANGE THE TWO LINES BELOW
$email_to = "kavik_609@hotmail.com";

$email_subject = "website html form submissions";


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 />";
    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 = "";
$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 />';
}
$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 />';
}
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.

";

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)."
";
$email_message .= "Last Name: ".clean_string($last_name)."
";
$email_message .= "Email: ".clean_string($email_from)."
";
$email_message .= "Telephone: ".clean_string($telephone)."
";
$email_message .= "Comments: ".clean_string($comments)."
";


// create email headers
$headers = 'From: '.$email_from."
".
'Reply-To: '.$email_from."
" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  


print "<!doctype html>";
print "<html>";
print "<head>";
print "<meta charset="UTF-8">";
print "<title>This & That Unique Designs by Megan Gifford</title>";
print "<meta name="keywords" content="Mecosta County, Big Rapids, Unique, Design, Custom Creations, Florist, Megan Gifford">";
print "<meta name="description" content="This & That: Unique Designs by Megan Gifford">";
print "<link href="thisthat.css" rel="stylesheet" type="text/css">";
print "</head>";

print "<body>";


print "<div id="page">";

print "<img src="images/slideshow/image_7.jpg" width="235" height="992" alt="Second Image" />";




print "<div class="content">";

print "<div class="header">";
print "<img src="logo/header.png" alt="Header">";
print "</div>";






print "<div class="horizontal">";
print "<ul id="nav-bar">";
print "<li class="links"><a href="index.html">Home</a></li>";

print "<li class="links"><a href="#">Events</a>";
print "<ul class="linkshover">";
print "<li class="linkshover"><a href="#">Weddings</a></li>";
print "<li class="linkshover"><a href="#">Funerals</a></li>";
print "<li class="linkshover"><a href="#">Family Gatherings</a></li>";
print "<li class="linkshover"><a href="#">Celebrations</a></li>";
print "<li class="linkshover"><a href="#">Interior Design</a></li>";
print "</ul></li>

print "<li class="links"><a href="#">Gallery</a>";
print "<ul class="linkshover">";
print "<li class="linkshover"><a href="#">Weddings</a></li>";
print "<li class="linkshover"><a href="#">Repurpose Projects</a></li>";
print "<li class="linkshover"><a href="wreaths.html">Custom Wreaths</a></li>";
print "<li class="linkshover"><a href="#">Everyday Flowers</a></li>";
print "<li class="linkshover"><a href="#">Interior Design</a></li>";
print "<li class="linkshover"><a href="#">Head Pieces</a></li>";
print "<li class="linkshover"><a href="#">Odds & Ends</a></li>";
print "</ul></li>";

print "<li class="links"><a href="bloghome.html">Blog</a>";
print "<ul class="linkshover">";
print "<li class="linkshover"><a href="#">Link</a></li>";
print "</ul></li>";

print "<li class="links"><a href="#">Contact</a></li>";

print "</ul>";
print "</div>";

print "<p>Thank you for contacting us. We will be in touch with you very soon.</p>";

print "<div class="footer">";

print "<div id="social">";
print "<a href="https://www.facebook.com/pages/This-That-Unique-Designs-by-Megan-Gifford/978137455546948" target="_blank"><img src="logo/facebook.png" alt="Facebook"></a>";
print "<a href="https://twitter.com/wendyamstar" target="_blank"><img src="logo/pinterest.png" alt="Pinterest"></a>";
print "<a href="http://www.panduvie.com/wendyamstar" target="_blank"><img src="logo/instagram.png" alt="Instagram"></a>";
print "</div>";

print "<img src="logo/footer.png" alt="Footer">";

print "</div>";

print "</div>";


print "</div>";





print "</body>";
print "</html>";
?>

<?php
}
die();
?>
</div>
  • 写回答

1条回答 默认 最新

  • doucheng8471 2015-09-17 02:47
    关注

    You have problem with " convension .

    "" won't allow another " inside it boundary until you escape it

    you can use ' inside "" or you can use " inside ' '

    or you can escape it like this

    print "<meta charset=\"UTF-8\">";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗