dsxrq28228 2015-10-04 00:45
浏览 73

我使用javascript提交表单但我无法在php页面中获取值

I am using this code to submit my form

    $('.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;
        }
    });

I am not able to get values in check.php. kindly help me. I know its a basic thing but I am not able to do this. Thanks in advance

Here is my php code

       <?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);
       }

       ?>

Here i just need usertype, username and password to make login decisions

  • 写回答

2条回答 默认 最新

  • donglu5612 2015-10-04 03:00
    关注

    I notice you're referencing $('.login-form') in one section of your code and $('#login-form') in another. If your form is in fact using a class instead of an ID, the .serialize() method will return an empty array. Update it to $('.login-form input') (note the period instead of the hash).

    More info on jQuery selectors: https://api.jquery.com/category/selectors/

    评论

报告相同问题?

悬赏问题

  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因