我是初学者,我正在尝试使用此tutoriel http://untame.net/2013/05/how-to-build-a-modal-contact-form-in-twitter-bootstrap-with-php-ajax来创建我的联系表单。电子邮件不发送!你知道吗,为什么?谢谢你的帮助!
点击发送后,我在adresse网站上发布了此内容:http://viktorius.fr/?question=&email=&save=contact
这里是HTML代码:
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><img src="img/glyphicons_012_heart.png"></span>
<input id="login-username" type="text" class="form-control" name="username" value="" placeholder="What is your question ?">
</div>
<h5 id="Email" align="left" color="#000"<span style="color:black">For the answer, let us your email :</h5>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><img src="img/glyphicons_290_skull.png"></span></span>
<input id="login-username" type="text" class="form-control" name="username" value="" placeholder="Email">
</div>
<!-- Form itself -->
<div class="form-actions">
<input type="hidden" name="save" value="contact">
<button type="submit" class="btn btn-primary pull-right">Send</button><br />
这里是PHP代码:
<?php
ini_set(“SMTP”,”smtp.viktorius.fr”);
ini_set(“smtp_port”,”25″);
$myemail = 'postmaster@viktorius.fr';
if (isset($_POST['question'])) {
$email = strip_tags($_POST['email']);
echo "<span class=\"alert alert-success\" >Your message has been received. Thanks! Here is what you submitted:</span><br><br>";
echo "<stong>Question:</strong> ".$question."<br>";
echo "<stong>Email:</strong> ".$email."<br>";
答案 0 :(得分:0)
if (isset($_POST['name']))
<input id="login-username" type="text" class="form-control" name="username" value="" placeholder="What is your question ?">
检查输入的名称,php无法读取您的帖子数据。
答案 1 :(得分:0)
这里没有单一表格......
ajax期望序列化
<form class="contact">...
$('form.contact').serialize(),
你没有表格 您应该将所有输入和按钮放在带有类联系人的表单标记中,如下所示:
<form action="" class="contact">
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><img src="img/glyphicons_012_heart.png"></span>
<input id="login-username" type="text" class="form-control" name="username" value="" placeholder="What is your question ?">
</div>
<div style="margin-bottom: 25px;" class="input-group">
<span class="input-group-addon"><img src="img/glyphicons_290_skull.png"></span>
<input id="login-username" type="text" class="form-control" name="username" value="" color="#000000"placeholder="For the answer, let us your email adress here :">
</div>
<div class="form-actions">
<input type="hidden" name="save" value="contact">
<button type="submit" class="btn btn-primary pull-right">Send</button><br>
</div>
</form>