我正在做一个非常简单的订阅表单,用户填写姓名和电子邮件,然后按订阅按钮。
我不明白为什么这不起作用..这里有什么遗漏吗?
<form class="form-signin" role="form" name='subscriptionForm' action='/' method='post'>
<h4 class="form-signin-heading">Get new articles via email</h4>
<input type="text" class="form-control" name="name" placeholder="Name" required autofocus>
<br/>
<input type="text" class="form-control" name="email" placeholder="Email address" required autofocus>
<br/>
<button class="btn btn-lg btn-primary btn-block" data-toggle="dropdown" type="submit">Subscribe Me!</button>
<br/><br/>
<?php
if (isset($_REQUEST['name']) && isset($_REQUEST['email']) )
//if email is filled out, send email
{
$to = "myemail@gmail.com";
$subject = "Thngs Of That Nature | Article Subscription";
$name = $_POST['name'] ;
$message = 'Hello there, I would like to subscribe to Thngs Of That Nature!' ;
$from = $_REQUEST['email'] ;
$headers = $name .'( '. $from .' )';
mail($to, $subject, $message, $headers);
echo "<div class='fb'>Awe! <b>" .$name ." Stay sharP!";
} else {
echo "NOPE!";
};
?>
</form>
答案 0 :(得分:-1)
有2个问题。
1) data-toggle="dropdown"
拦截HTTP调用,因此<?php .... ?>
不会被执行。我不得不删除属性。
2)将$_REQUEST[]
与$_POST[]
混合似乎导致了一系列问题,我只能使用一个,而且我必须使用$_POST[]
。< / p>