当前位置:网站首页>PHP page value transfer
PHP page value transfer
2022-07-26 08:54:00 【Miracle Fan】
PHP Page transfer value
List of articles
1.Form Form transfer value
Front page :
<form action="login.php" method="post">
<label><input class="text" type="text" placeholder=" user name " name="username"/></label><br>
<label><input class="text" type="password" placeholder=" password " name="password"/></label><br>
<label><select size="1" class="text" style="width:95px;height:25px;" name="identity">
<option> Student </option>
<option> Administrators </option>
</select></label><br>
<label><input class="submit" type="submit" name="submit" value=" Sign in "/></label>
</form>
Back end page login.php
Through the front end input Data selected in the input box , From the back end through the selected method Method
$username = $_POST['username'];
$password = $_POST['password'];
$identity = $_POST['identity'];
// If you choose get The way
$username = $_GET['username'];
$password = $_GET['password'];
$identity = $_GET['identity'];
2.< a > Link transfer value
In all the similar href Links can be transferred and adjusted in the following form .
front end : You can use string functions to splice calls and pass values .
<a href="test.php?haha=3&ha=4"> test </a>
Back end fetch value : The URL during transmission is as follows , You can see many corresponding passes GET Method retrieval .
//http://localhost:63342/upload_multi.php/test.php?haha=3&ha=4
$user=$_GET['haha'];
$name=$_GET['ha'];
echo $user,$name;
3.Cookie and Session
Cookie Is equivalent to automatically generating a cookie Files are used to store data , When the file expires, it will be automatically deleted .
session Be similar to cookie Will generate a random id As session The name of the file , Stored in the memory of the server , When closing the page ,id It will log out automatically .
Set up cookie as well as session
setcookie('username', $userName, time() + 18000);
setcookie('identity', $identity, time() + 3600);// Set an hour
session_start();
$_SESSION['username'] = $userName;
call cookie and session
$username=$_COOKIE['username'];
$identity=$_COOKIE['identity'];
session_start();
$username=$_SESSION['username']
4.AJAX Pass value ( Advanced processing )
front end :
<form action="" method="post" οnsubmit=>
<label><input class="text" type="text" placeholder=" user name " name="username"/></label><br>
<label><input class="text" type="password" placeholder=" password " name="password"/></label><br>
<label><select size="1" class="text" style="width:95px;height:25px;" name="identity">
<option> Student </option>
<option> Administrators </option>
</select></label><br>
<label><input class="submit" type="submit" name="submit" value=" Sign in "/></label>
</form>
<script> function _(el) {
return document.getElementById(el); } function uploadFile() {
let content = _('text').value; const formdata = new FormData();// Generate formdata For data transfer let i, temp; time = getCurrentDate(); unique_arr.push(temp); formdata.append('content', content); formdata.append('username', username); for (i = 0; i < unique_arr.length; i++) {
formdata.append('unique[]', unique_arr[i]); } t2 = window.setInterval("clock()", 1500) var ajax = new XMLHttpRequest(); ajax.open("POST", "test.php"); ajax.send(formdata); } </script>
Back end :
ajax.open("POST", "test.php"); According to the selected method and page , You can choose the page through POST Method to call the value
边栏推荐
- Replication of SQL injection vulnerability in the foreground of Pan micro e-cology8
- 海内外媒体宣发自媒体发稿要严格把握内容关
- P1825 [USACO11OPEN]Corn Maze S
- [untitled]
- Excel delete blank lines
- 2000年的教训。web3是否=第三次工业革命?
- Leetcode and query question summary
- Spark scheduling analysis
- One click deployment of lamp and LNMP scripts is worth having
- Store a group of positive and negative numbers respectively, and count the number of 0 -- assembly language implementation
猜你喜欢

tcp 解决short write问题

1、 Redis data structure

03 exception handling, state keeping, request hook -- 04 large project structure and blueprint

Xshell batch send command to multiple sessions

Excel find duplicate lines

Learning notes of automatic control principle --- linear discrete system

Super potential public chain dfinity -- the best time for DFI developers to enter

Excel delete blank lines

idea快捷键 alt实现整列操作

解决C#跨线程调用窗体控件的问题
随机推荐
Analysis on the query method and efficiency of Oracle about date type
Install HR schema, example, and Scott schema on Oracle and MySQL
Oracle 19C OCP 1z0-082 certification examination question bank (36-41)
Arbitrum Nova release! Create a low-cost and high-speed dedicated chain in the game social field
Kept dual machine hot standby
Excel delete blank lines
机器学习中的概率模型
C Entry series (31) -- operator overloading
TypeScript版加密工具PasswordEncoder
Memory management based on C language - Simulation of dynamic partition allocation
解决C#跨线程调用窗体控件的问题
Winter vacation homework & Stamp cutting
Spark SQL common date functions
node的js文件引入
What are the differences in the performance of different usages such as count (*), count (primary key ID), count (field) and count (1)? That's more efficient
Ueditot_ JSP SSRF vulnerability recurrence
【LeetCode数据库1050】合作过至少三次的演员和导演(简单题)
P3743 Kotori's equipment
JDBC database connection pool (Druid Technology)
Oracle 19C OCP 1z0-082 certification examination question bank (30-35)