How to implement form method
Automatic submission of form forms is also a problem we encounter in regular projects.
For example, in the mall system we often see, if the user is a seller and wants to log in to the user seller's backend, our normal logic does not require the user to log in again, so we can use Automatically log in to the form, which is the automatic submission function.
Let me briefly explain it to you:
The general idea is: where ordinary members can log in, the user name, password and user ID can be saved after successful login. For security reasons, we can use AES encryption and store it in cookies. When the user visits the seller's backend management page, we can determine the information in the stored cookie in the program and determine whether it is a seller. If it is a seller, we You can use the form to automatically log him in.
Simply take the automatic submission function of ecshop as an example:
Create a phpcn_form.php under includes:
<?php class form{ public function hform($username,$password){ $str = '<body><form action="phpcn.php" method="post" id="phpcn" name="phpcn" 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; } }?>
In the signin method of phpcn.php, perform aes Decrypt and introduce the phpcn_form.php file.
<?php require_once(ROOT_PATH . 'includes/phpcn_form.php'); $form = new form(); $username = $j_token['username'];$password=$j_token['password']; $a = $form->hform($username,$password);exit; ?>
With a few simple lines of code, you can quickly implement the function of automatically submitting the form for login, so that the user only needs to log in once. Isn't it very simple? Everyone is welcome to comment, and we can learn and make progress together on the road of programming.
The above is the detailed content of How to implement form method. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Preface: vim is a powerful text editing tool, which is very popular on Linux. Recently, I encountered a strange problem when using vim on another server: when I copied and pasted a locally written script into a blank file on the server, automatic indentation occurred. To use a simple example, the script I wrote locally is as follows: aaabbbcccddd. When I copy the above content and paste it into a blank file on the server, what I get is: aabbbcccddd. Obviously, this is what vim does automatically for us. Format indentation. However, this automatic is a bit unintelligent. Record the solution here. Solution: Set the .vimrc configuration file in our home directory, new

With the development of the Internet, pictures have become an indispensable part of web pages. But as the number of images increases, the loading speed of images has become a very important issue. In order to solve this problem, many websites use thumbnails to display images, but in order to generate thumbnails, we need to use professional image processing tools, which is a very troublesome thing for some non-professionals. Then, using JavaScript to achieve automatic thumbnail generation becomes a good choice. How to use JavaS

If you are using a Linux operating system and want the system to automatically mount the drive on boot, you can do this by adding the device's unique identifier (UID) and mount point path to the fstab configuration file. fstab is a file system table file located in the /etc directory. It contains information about the file systems that need to be mounted when the system starts. By editing the fstab file, you can ensure that the required drives are loaded correctly every time the system starts, thus ensuring stable system operation. Automatically mounting drivers can be conveniently used in a variety of situations. For example, I plan to back up my system to an external storage device. To achieve automation, ensure that the device remains connected to the system, even at startup. Likewise, many applications will directly

MySQL transaction processing: the difference between automatic submission and manual submission. In the MySQL database, a transaction is a set of SQL statements. Either all executions are successful or all executions fail, ensuring the consistency and integrity of the data. In MySQL, transactions can be divided into automatic submission and manual submission. The difference lies in the timing of transaction submission and the scope of control over the transaction. The following will introduce the difference between automatic submission and manual submission in detail, and give specific code examples to illustrate. 1. Automatically submit in MySQL, if it is not displayed

PHP and PHPMAILER: How to implement automatic filtering of mail sending? In modern society, email has become one of the important ways for people to communicate. However, with the popularity and widespread use of email, the amount of spam has also shown an explosive growth trend. Spam emails not only waste users' time and network resources, but may also bring viruses and phishing behaviors. Therefore, when developing the email sending function, it becomes crucial to add the function of automatically filtering spam. This article will introduce how to use PHP and PHPMai

Tips for implementing form validation and submission with PHP and UniApp Introduction: When developing web pages or mobile applications, form validation and submission are essential functions. Form validation is used to check whether the data entered by the user conforms to specific rules, and submission saves or sends the data entered by the user to the server. This article will introduce the techniques of using PHP and UniApp to implement form validation and submission to help developers quickly implement front-end and back-end interaction functions. 1. PHP implements form validation. The following is a PHP form validation sample code for

Introduction to git Git is a distributed version control system, which means that each developer has a complete copy of the code base on their computer. This is different from a centralized version control system (such as Subversion or Perforce), which only has a central code repository. The benefit of distributed version control is that it makes collaboration more efficient because developers can work offline and synchronize with the central code base later. Installing Git To use Git, you need to install it on your computer first. You can download the installer for your operating system from the official Git website. After the installation is complete, you can enter git --version in the command line to check whether the installation was successful. Git basic concepts repository: Git

How to handle complex form submissions in Vue requires specific code examples. In Vue, to handle complex form submissions, you can use Vue's form processing methods and other related plug-ins or features to simplify the development process. This article will introduce how to use Vue and some other common plug-ins to handle complex form submissions, and provide specific code examples. 1. Two-way binding of form data One of the core features of Vue is the two-way binding of data. In form processing, we can use Vue instructions to achieve bidirectional communication between form data and views.
