我目前正在通过twitter bootstrap将联系表单部署到网站,其中表单发布到发送电子邮件给管理员的php脚本。问题是如果文件js/plugins/validator/jquery.form-validator.min.js
用于验证
当我删除以下验证文件时,我可以让表单正常运行并成功提交电子邮件:
js/plugins/validator/jquery.form-validator.min.js
来自页面底部的脚本部分,但这会删除表单上的所有验证
<form method="post" action="sendmail.php" class="input-group input-group-lg" id="subscribeForm" >
<input type="text class="form-control" placeholder="Name" id="name" name="name" />
<input type="text" name="company" class="form-control" placeholder="company" /><br />
<input type="text" name="phone" class="form-control" placeholder="phone" /><br />
<input type="email" class="form-control" placeholder="email" id="sEmail" name="email">
<span class="input-group-btn">
<input type="submit" button class="btn bg-primary">Invite Me!</button>
</span></form><!-- /input-group -->
sendmail.php的内容
<?php
$name = $_REQUEST['name'];
$company = $_REQUEST['company'];
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'];
$emess = "Name: ".$name."\n";
$emess.= "Company: ".$company."\n";
$emess.= "Email : ".$email."\n";
$emess.= "Phone number: ".$phone."\n";
mail( "send-to-email", "Information Request",
$emess, "From: $email" );
header( "Location: http://www.google.com" );?>
答案 0 :(得分:2)
在您的代码中
<input type="text class="form-control" placeholder="Name" id="name" name="name" />
^ right there
您在文字后缺少引用"
。扔进去,它应该工作。
在php方面需要注意的另一件事是,使用$name = $_POST['name'];
代替,因为您通过帖子发送表单,默认情况下$_REQUEST
包含$_GET
的内容,{{1 }和$_POST
。
编辑:正如Fred在输入按钮上指出的那样,它应该是
$_COOKIE
答案 1 :(得分:1)
更改了输入提交标记
<form method="post" action="sendmail.php" class="input-group input-group-lg" id="subscribeForm" >
<input type="text" class="form-control" placeholder="Name" id="name" name="name" />
<input type="text" name="company" class="form-control" placeholder="company" /><br />
<input type="text" name="phone" class="form-control" placeholder="phone" /><br />
<input type="email" class="form-control" placeholder="email" id="sEmail" name="email">
<span class="input-group-btn">
<input type="submit" value="Invite Me!" />
</span></form>