【发布时间】:2015-10-04 00:45:05
【问题描述】:
我正在使用此代码提交我的表单
$('.login-form input').keypress(function (e) {
if (e.which == 13) {
if ($('.login-form').validate().form()) {
//$( "#login-form input" ).submit();
// window.location.href = "check.php";
$.post("check.php", $("#login-form input").serialize(), function(data) {
window.location.href = "check.php";
});
}
return false;
}
});
我无法在 check.php 中获取值。请帮助我。我知道这是一件基本的事情,但我无法做到这一点。提前致谢
这是我的 php 代码
<?php
session_start();
include_once("Includes/db_connection.php");
include_once("participant/welcome.php");
include_once("admin/admin_login.php");
include_once("staff/staff_login.php");
include_once("lecturer/lecturer_login.php");
include("Includes/location.php");
//include("Includes/lecturer_data_dropdown.php");
$username=$_POST["username"];
$password=$_POST["password"];
echo $username;
if($_POST["user_type"]=="participant")
{
participant($password);
}
elseif($_POST["user_type"]=="admin")
{
admin($username, $password);
}
elseif($_POST["user_type"]=="staff")
{
staff($username, $password);
}
elseif($_POST["user_type"]=="lecturer")
{
lecturer($username, $password);
}
?>
在这里我只需要用户类型、用户名和密码来做出登录决定
【问题讨论】:
-
您正在使用
$.post(POST 动词)方法发布并立即重定向使用GET动词的用户,您期望什么? -
我想重定向到该页面并在 check.php 中获取表单数据,我将在其中做出重定向决定。请帮我。我被卡住了
标签: javascript php jquery html ajax