In the project, such as business-to-business from the mall to jump to the seller center backstage, when he has a member account is the seller's time, let him login to the mall, do not need to login the seller, the process can be used in the form form automatic login. This article is mainly for everyone to bring a form to automatically submit an example to explain. Small series feel very good, now share to everyone, also for everyone to make a reference. Follow the small series together to see it, hope to help everyone.
To achieve a simple idea: can be a normal member login, login success can be login and password, user ID saved, in order to secure AES encryption (the previous article has detailed introduction), deposit cookies, in the page need to go to the seller center, there can judge the beginning of the cookie, and determine if it is a seller, and if so, use the form form to automatically log him in.
Examples implemented on Ecshop:
Create a lib_stm_form.php below the includes:
Class form{public function Hform ($username, $password) { $str = ' <body><form action= ' privilege.php ' Method= "POST" id= "Qqform" name= "Qqform" style= "Display:none" > "; $str. = ' Account: <input type= "text" name= "username" value= ". $username. '/><br/> '; $str. = ' Password: <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; }}? >
In the Signin method of the privilege.php, AES decryption is carried out, and the lib_stm_form.php is introduced:
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;
In this way, the automatic submission of form login, if it is the membership and the identity of the seller, you can achieve a login once good.