php - PHP联系人表单在 IE mywebsite.com/php/form.php 下工作,但它的设置为默认 index.php IE mywebsite.com

  显示原文与译文双语对照的内容
0 0

在这里,我找到了一个问题,当我试图在我的网站上实现代码时,这是用 Bootstrap 制作的。 我还用 Bootstrap 和php制作了这个天气机,它最终在默认 index.php IE 下工作。 website.com

代码。用myEmail替换我的邮件

PHP

<?php
if ($_POST["submit"]) {
 if (!$_POST['name']) {
 $error="<br/>Please enter your name";
 }
 if (!$_POST['email']) {
 $error.="<br/>Please enter your email address";
 }
 if (!$_POST['comment']) {
 $error.="<br/>Please enter a comment";
 }
 if ($_POST['email']!="" AND!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { 
 $error.="<br/>Please enter a valid email address";
 } 
 if ($error) {
 $result='<div class="alert alert-danger"><strong>There were errors(s) in your form:</strong>'.$error.' </div>';
 } else {
 if (mail("myEmail","Comment from Website!","Name:".$_POST['name']."
 Email:".$_POST['email']."
 Comment:".$_POST['comment'])) {
 $result='<div class="alert alert-success"><strong>Thank you!</strong>I'll be in touch.</div>';
 } else {
 $result='<div class="alert alert-danger"><strong>Sorry, there was an error 
 sending your message. Please try again.</strong></div>';
 } 
 } 
}

>

HTML

<body>
<div class="container">
 <div class="row">
 <div class="col-md-6 col-md-offset-3 emailForm">
 <h1>Email Us</h1>
 <?php echo $result;?>
 <p class="lead">Please get in touch, and we will get back to you asap.</p>
 <form method="post">
 <div class="form-group">
 <label for="name">Name:</label>
 <input type="text" name="name" class="form-control" placeholder="Name"
 value="<?php echo $_POST['name'];?>"/>
 </div>
 <div class="form-group">
 <label for="email">Email:</label>
 <input type="email" name="email" class="form-control" placeholder="Email"
 value="<?php echo $_POST['email'];?>"/>
 </div>
 <div class="form-group">
 <label for="comment">Comment:</label>
 <textarea class="form-control" name="comment" value="<?php echo $_POST['comment'];?>"></textarea>
 </div>
 <input type="submit" name="submit" class="btn btn-success btn-lg" value="Submit"/>
 </form>
 </div>
 </div>
</div>
时间:原作者:6个回答

0 0

我看不到任何明显的效果,

<form method="post">

 <form method="post" action="/index.php">

如果PHP代码的位置是 http://website.com/index.php

原作者:
...