gpt4 book ai didi

php - 我正在尝试在 php 中运行邮件表单。这是带有 Bootstrap 3.0 的 HTML

转载 作者:搜寻专家 更新时间:2023-10-31 21:07:42 41 4
gpt4 key购买 nike

我正在为一个使用框架 Twitter Bootstrap 3.0 的网站制作联系页面。这是 HTML。

<form action="mail.php" name="contactform"  method="post" id="contact-form">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name"> Name</label>

<input id="name" class="form-control" type="text" name="name" placeholder="Enter you name" value="" required/>

</div>
<div class="form-group">
<label for="email">Email Address</label>
<div id="input_email" class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
<input id="email" class="form-control" type="email" name="email" placeholder="Enter your email" value="" required />
</div>
</div>

<div class="form-group">
<label for="subject"> Subject</label>

<input id="subject" class="form-control" type="text" name="subject" placeholder="Subject"/>

</div>

</div>

<div class="col-md-6">
<div id="input_message" class="col-md-12">
<textarea id="comments" class="form-control" name="message" rows="6" placeholder="Your Suggestion ..." value="" required ></textarea>
</div>
</div>
<!-- Submit Button -->
<div class="col-md-12">

<input class="btn btn-skin pull-right" type="submit" value="submit" id="submit">
</div>

</div>

</form>

这是 PHP:

<!DOCTYPE html>
  <head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content=" Contact Form Validation.">
<meta name="author" content="Julian Vanegas">
<title>Mailing</title>
<!--Favicon-->
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<!-- Bridge -->
<link href="bridge-contactphp.css.css" rel="stylesheet" type="text/css">
</head>

<body id="page-top" data-spy="scroll" data-target=".navbar-custom">
<!-- Preloader -->
<div id="preloader">
<div id="load"></div>
</div>

<!--Navbar-->
<nav class="navbar navbar-custom navbar-fixed-top top-nav-collapse" role="navigation">
<div class="container">
<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse">
<i class="fa fa-bars"></i>
</button>
<a class="navbar-brand" href="#page-top">
<img src="img/logo-svg.svg"class="logo"></img>
</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-right navbar-main-collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About us</a></li>
<li><a href="about.html#services">Services</a></li>
<li class="active"><a href="contact.html">Contact</a></li>
<li><a href="sitemap.html">Sitemap</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle " data-toggle="dropdown">More<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Globalnode Acad</a></li>
<li><a href="#">Community</a></li>
<li><a href="#"></a></li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>

<?php
$form_htmlString = "";
if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['subject']) || empty($_POST['message'])){
$form_htmlString = <<<EOD
<section id=\"intro\" class=\"intro\"><div class=\"gallery-intro\"><h2> <span class=\"text_color\"> <span>fadfasfads</span> </h2><h4></h4></div><div class=\"page-scroll\"><a href=\"#sitemap\" class=\"btn btn-circle\"><i class=\"fa fa-angle-double-down animated\"></i></a></div></section><div class=\"container\"> <div class=\"row\"> <div class=\"col-xs-12 col-sm-12 col-md-12 text-center padding-20\"><div class=\"wow bounceInUp\" data-wow-delay=\"0.2s\"> <div class=\"team boxed-grey\"> <div class=\"inner\"><h5 alt=\"Internal-link List\"> Check the information you typed in. </h5> <p class=\"subtitle\"> There is one or more mistakes. </p></div></div></div></div></div></div>
EOD;
}else{
$sendTo = "jumisingo@hotmail.es";
$subject ="Mensaje de contacto";
$title = "Alguien se ha contactado con usted";
$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$comments = $_POST["message"];
$message = "\nAlguien se ha contactado con usted:"."\nNombre: ".$name."\nEmail: ".$email."\nAsunto: ".$subject."\nComentarios: ".$comments;
mail($sendTo, $subject, $message);
$form_htmlString = "<section id=\"intro\" class=\"intro\"><div class=\"gallery-intro\"><h2> <span class=\"text_color\"> <span>fadfasfads</span> </h2><h4></h4></div><div class=\"page-scroll\"><a href=\"#sitemap\" class=\"btn btn-circle\"><i class=\"fa fa-angle-double-down animated\"></i></a></div></section><div class=\"container\"> <div class=\"row\"> <div class=\"col-xs-12 col-sm-12 col-md-12 text-center padding-20\"><div class=\"wow bounceInUp\" data-wow-delay=\"0.2s\"> <div class=\"team boxed-grey\"> <div class=\"inner\"><h5 alt=\"Internal-link List\"> Check the information you typed in. </h5> <p class=\"subtitle\"> There is one or more mistakes. </p></div></div></div></div></div></div>";
echo $form_htmlString;
}
?>

<footer id="sitemap"><div class="container"><div class="row"><div class="col-md-12 col-lg-12"><div class="wow shake" data-wow-delay="0.4s"><div class="page-scroll marginbot-30 pull-right"><a href="#intro" id="totop" class="btn btn-circle"><i class="fa fa-angle-double-up animated"></i></a></div></div><p>&copy;Copyright 2015 - Global Node Inc. All rights reserved.</p></div></div></div></footer>

</body>

当我运行 if 时,它应该评估通过 ifs 在 HTML 中输入的数据,并根据中断回显 html,但它也会回显部分 php。我已经搜索了解决方案,我看到 heredoc 有效,但在这种情况下它没有。有什么线索吗?

最佳答案

"This is what the server replies." Parse error: syntax error, unexpected '"', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home2/ina2015/public_html/gna/contact.php on line 76"

错误出在您的 heredoc 的这段代码中。

<?php
$form_htmlString = "";
if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['subject']) || empty($_POST['message'])){
$form_htmlString = <<<EOD
<section id=\"intro\" class=\"intro\"><div class=\"gallery-intro\"><h2> <span class=\"text_color\"> <span>fadfasfads</span> </h2><h4></h4></div><div class=\"page-scroll\"><a href=\"#sitemap\" class=\"btn btn-circle\"><i class=\"fa fa-angle-double-down animated\"></i></a></div></section><div class=\"container\"> <div class=\"row\"> <div class=\"col-xs-12 col-sm-12 col-md-12 text-center padding-20\"><div class=\"wow bounceInUp\" data-wow-delay=\"0.2s\"> <div class=\"team boxed-grey\"> <div class=\"inner\"><h5 alt=\"Internal-link List\"> Check the information you typed in. </h5> <p class=\"subtitle\"> There is one or more mistakes. </p></div></div></div></div></div></div>
EOD;
^^^^^^^^^^^^^^ It contains spaces. There should not be any.

您的结束标识符前后不应有任何内容。

修改为:(EOD;前后没有空格)

<?php
$form_htmlString = "";
if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['subject']) || empty($_POST['message'])){
$form_htmlString = <<<EOD
<section id=\"intro\" class=\"intro\"><div class=\"gallery-intro\"><h2> <span class=\"text_color\"> <span>fadfasfads</span> </h2><h4></h4></div><div class=\"page-scroll\"><a href=\"#sitemap\" class=\"btn btn-circle\"><i class=\"fa fa-angle-double-down animated\"></i></a></div></section><div class=\"container\"> <div class=\"row\"> <div class=\"col-xs-12 col-sm-12 col-md-12 text-center padding-20\"><div class=\"wow bounceInUp\" data-wow-delay=\"0.2s\"> <div class=\"team boxed-grey\"> <div class=\"inner\"><h5 alt=\"Internal-link List\"> Check the information you typed in. </h5> <p class=\"subtitle\"> There is one or more mistakes. </p></div></div></div></div></div></div>
EOD;

来自手册:

It is very important to note that the line with the closing identifier must contain no other characters, except a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system. This is \n on UNIX systems, including Mac OS X. The closing delimiter must also be followed by a newline.

关于php - 我正在尝试在 php 中运行邮件表单。这是带有 Bootstrap 3.0 的 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29681371/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com