• form自动提交


    在做项目中,例如b2b的由商城跳往卖家中心的后台,当他既有会员账号又是卖家的时候,让他登录了商城,就不需要卖家登录的时候,处理过程中可以用到form表单自动登录

    实现简单思路:可以在普通会员登录的地方,登陆成功可以将登录名和密码,用户ID存起来,为了安全可以aes加密,存入cookie,在页面中需要去卖家中心,那边可以判断开始所存的cookie,以及判断是否是卖家,

    如果是,用form表单自动给他登录

    在ecshop上面实现的案例:

    在includes下面创建一个lib_stm_form.php:

    class form{

      public function hform($username,$password){

    $str='<body><form action="privilege.php" method="post"  id="qqform" name="qqform" style="display:none">';

    $str .='账号:<input type="text" name="username" value="'.$username.'"/><br/>';

    $str .='密码:<input type="text" name="password" value="' .$password .'"/><br/>';

    $str .='<input type="hidden" name="act" value="signin"/></form></body>

    $str .='<script>window.onload=function(){ document.getElementById("qqform").submit();}</script>

    echo $str;exit;

    }

    }

    ?>

    在privilege.php 的signin方法中,进行aes解密,引入lib_stm_form.php:

    require_once(ROOT_PATH . 'includes/lib_smt_from.php');

    $form =new form();

    $username =$j_token['username'];

    $password=$j_token['password'];

    $a=$form->hform($username,$password);

    exit;

    这样就实现了,form的自动提交登录,如果是会员和卖家身份的,就可以实现了登录一次就好

  • 相关阅读:
    Light oj 1197
    UVA 11426 GCD
    Light oj 1236
    Light oj 1138
    Light oj 1214-Large Division (同余定理)
    Light oj 1234
    HDU
    ZOJ 3469 Food Delivery(* 区间DP 总结)
    二分查找整理
    zoj 3965 Binary Tree Restoring(* dfs)
  • 原文地址:https://www.cnblogs.com/zzp0320/p/7145491.html
Copyright © 2020-2023  润新知