问题:我无法在我的电子邮件中获得用户提交的表单数据。当用户点击提交,表单刷新,但不发送任何电子邮件给我。如果有人发现这里有什么错误。我真的提前谢谢你。
HTML代码:<div class="content">
<h1>Contact Us</h1>
<form role="form">
<div class="form-group">
<form action="email.php" method="post">
<input type="text" class="form-control" name="name" id="exampleInputName" placeholder="Your good name" required>
<label for="exampleInputName"><i class="icon-tag"></i></label>
<div class="clearfix"></div>
</div>
<div class="form-group">
<input type="email" class="form-control" name="email" id="exampleInputEmail1" placeholder="Enter your email address" required>
<label for="exampleInputEmail1"><i class="icon-inbox"></i></label>
<div class="clearfix"></div>
</div>
<div class="form-group textarea">
<textarea rows="6" class="form-control" name="message" id="exampleInputMessage" placeholder="How can we help your business" required></textarea>
<label for="exampleInputMessage"><i class="icon-pencil"></i></label>
<div class="clearfix"></div>
</div>
<input type="submit" name="submit" class="btn btn-large" value="Send Message"> </button>
</form>
</div>
</div>
输入代码
PHP代码:<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: TangledDemo';
$to = 'danish@cloudtechteam.com';
$subject = 'Hello';
$body = "From: $name'n E-Mail: $email'n Message:'n $message";
$host = "mail.cloudtechteam.com";
$port = "25";
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,));
$mail = $smtp->send($to, $headers, $body);
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
?>
您的表单正在使用get方法,这是<form>
的默认值。将窗体更改为
<form role="form" method="post">