客户端验证是否干扰服务器端重定向?

时间:2016-06-09 15:33:44

标签: javascript php jquery

我正在使用jQuery插件(http://www.runningcoder.org/jqueryvalidation/)来验证客户端的数据。如果一切顺利,用户在点击提交时将被定向到另一个页面。如果我注释掉插件脚本部分,这可以正常工作,但是当它被包含时不会。

老实说,我有点困惑。我没有收到“已发送的标头”消息,我认为如果数据无效,插件将停止甚至进入服务器 - 这意味着如果包含它,它应该对PHP有点不同或不。

我错过了什么?

我的主要PHP页面的开头

    echo "<input type='submit' name='submitInsurance' value='Submit' /></form>";
    } 
include('footer.php');

?>
<script>

$("#mainForm").validate({
submit: {

    settings: {
    errorListContainer: '.formGroup',
     }
    }
}); 

我主要PHP的尾端

<?php

echo "</div><footer>Copyright Mid-America Hotels Corporation " . date("Y") . "</footer></html>";

footer.php

<?php

session_start();
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);

 error_reporting(E_ALL);

require('includes.php');


$host = '';
$user = '';
$pass = '';

$db = new dataBaseAccess($host, $user, $pass);

// if user is attempting to login...
if(!isset($_POST['submitInsurance'])) {
if(isset($_POST['login'])) {
$user = formatInput($_POST['user']);
$ssn = formatInput($_POST['ssn']);
if($db->verifyUser($user, $ssn, 'insurance_validation'))  {
$_SESSION['verified'] = true;
$_SESSION['userLast'] = $user;
$_SESSION['userSSN'] = $ssn; 
header('Location: insurance.php');

}
else {
echo "<!doctype html><head><link rel='stylesheet' href='styles/base.css' /><script src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js'></script><script src='scripts/validation.js'><script src='scripts/base.js'></script><title>Insurance Mid-Am</title></head><body><header><img src='logo.png' alt='Mid-America Hotels'><h1>Insurance Enrollment</h1></header><div id='mainContent'><h2 class='error'>Invalid Login Credentials!</h2>";
} 
}
else {
echo "<!doctype html><head><link rel='stylesheet' href='styles/base.css' /><script src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js'></script><script src='scripts/validation.js'></script><script src='scripts/base.js'></script><title>Insurance Mid-Am</title></head><body><header><img src='logo.png' alt='Mid-America Hotels'><h1>Insurance Enrollment</h1></header><div id='mainContent'>";
}
}

?>

的header.php

public class JsonPage<T> extends org.springframework.data.domain.PageImpl<T> {

public JsonPage(final List<T> content, final Pageable pageable, final long total) {
    super(content, pageable, total);
}

public JsonPage(final List<T> content) {
    super(content);
}

public JsonPage(final Page<T> page, final Pageable pageable) {
    super(page.getContent(), pageable, page.getTotalElements());
}

@JsonView(JsonViews.UiView.class)
public int getTotalPages() {
    return super.getTotalPages();
}

@JsonView(JsonViews.UiView.class)
public long getTotalElements() {
    return super.getTotalElements();
}

@JsonView(JsonViews.UiView.class)
public boolean hasNext() {
    return super.hasNext();
}

@JsonView(JsonViews.UiView.class)
public boolean isLast() {
    return super.isLast();
}

@JsonView(JsonViews.UiView.class)
public boolean hasContent() {
    return super.hasContent();
}

@JsonView(JsonViews.UiView.class)
public List<T> getContent() {
    return super.getContent();
}
}

编辑:原因是,由于某种原因,$ _POST ['submitInsurance']没有被发送。使用var_dump,看起来其他数据被发送,但是按钮的值。为什么会这样?

0 个答案:

没有答案