Form realizes automatic submission of code sharing

小云云
Release: 2023-03-20 06:30:01
Original
1888 people have browsed it

When working on a project, for example, a B2B person jumps from the mall to the backend of the seller center. When he has both a member account and a seller, and lets him log in to the mall, there is no need for the seller to log in. During the processing, Use form to log in automatically. This article mainly brings you an example of form automatic submission. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor to take a look, I hope it can help everyone.

Simple idea: you can log in as an ordinary member. If you log in successfully, you can save your login name, password, and user ID. For security, you can encrypt it with AES (detailed introduction in the previous article) and store it in cookies. On the page, you need to go to the seller center, where you can determine the cookie that was initially saved and whether it is a seller. If so, use the form to automatically log him in.

Case implemented on ecshop:

Create a lib_stm_form.php under includes:


class form{
  public function hform($username,$password){
    $str = &#39;<body><form action="privilege.php" method="post" id="qqform" name="qqform" style="display:none"> &#39; ;
    $str .= &#39;账号:<input type="text" name="username" value="&#39; . $username . &#39;" /><br />&#39; ;
    $str .= &#39;密码:<input type="text" name="password" value="&#39; . $password . &#39;" /><br />&#39; ;
    $str .=&#39;<input type="hidden" name="act" value="signin" /></form></body>&#39;;
    $str .= &#39;<script>window.onload= function(){document.getElementById("qqform").submit();}</script>&#39;;
    echo $str; exit;
  }
}
?>
Copy after login

In the signin method of privilege.php, perform aes decryption and introduce lib_stm_form.php::


require_once(ROOT_PATH . &#39;includes/lib_smt_from.php&#39;);
$form   = new form();
$username = $j_token[&#39;username&#39;];
$password   =$j_token[&#39;password&#39;];
$a = $form->hform($username,$password);
exit;
Copy after login

This is achieved. The form is automatically submitted for login. If you are a member or seller, you can log in once.

Related recommendations:

How to solve the problem of automatically submitting the form after pressing Enter in the web page and jumping to other pages

HTML Form tag usage

Detailed explanation of HTML Form form elements

The above is the detailed content of Form realizes automatic submission of code sharing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!