当前位置:网站首页>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
边栏推荐
- TypeScript版Snowflake主键生成器
- After MySQL 8 OCP (1z0-908), hand in your homework
- Review notes of Microcomputer Principles -- zoufengxing
- Install HR schema, example, and Scott schema on Oracle and MySQL
- Day06 homework -- skill question 2
- [search topics] flood coverage of search questions after reading the inevitable meeting
- [encryption weekly] has the encryption market recovered? The cold winter still hasn't thawed out. Take stock of the major events that occurred in the encryption market last week
- Introduction to AWD attack and defense competition
- Recurrence of SQL injection vulnerability in the foreground of a 60 terminal security management system
- day06 作业--增删改查
猜你喜欢

PXE principles and concepts

Kotlin properties and fields

idea快捷键 alt实现整列操作

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

Arbitrum launched the anytrust chain to meet the diverse needs of ecological projects

Review notes of Microcomputer Principles -- zoufengxing

Day 6 summary & database operation

Database operation skills 7

第6天总结&数据库作业
![[untitled]](/img/89/c3ab79eb325f0136114a568745924b.png)
[untitled]
随机推荐
day06 作业--技能题6
Vision Group Training Day5 - machine learning, image recognition project
P3743 kotori的设备
解决C#跨线程调用窗体控件的问题
Registration of finite element learning knowledge points
Kotlin properties and fields
Pan micro e-cology8 foreground SQL injection POC
Set of pl/sql -2
Spark scheduling analysis
Day06 homework - skill question 6
6、 Pinda general permission system__ pd-tools-log
Recurrence of SQL injection vulnerability in the foreground of a 60 terminal security management system
[freeswitch development practice] use SIP client Yate to connect freeswitch for VoIP calls
Overview of motion recognition evaluation
[recommended collection] MySQL 30000 word essence summary + 100 interview questions (I)
PXE principles and concepts
My meeting of OA project (meeting seating & submission for approval)
[suggestions collection] summary of MySQL 30000 word essence - locking mechanism and performance tuning (IV) [suggestions collection]
【LeetCode数据库1050】合作过至少三次的演员和导演(简单题)
day06 作业--技能题2