Form implementation Auto-commit code sharing

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.