Home  >  Article  >  Backend Development  >  Another way to use the GET and POST methods of PHP program to process web forms_PHP tutorial

Another way to use the GET and POST methods of PHP program to process web forms_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:36:22756browse

Sometimes we need to retain GET and POST parameters to pass on the next page or other purposes!
It’s convenient for work, so I wrote this code!
Hope everyone can communicate more!

/*
Programming: Lin Jianxuan (Piaofeng Design Studio)
made in Zhuhai by 2007-03-24
QQ: 5818500
Email: linzhenxuan@163 .com
Do not delete this copyright information
Purpose: retain and modify GET and POST parameters
*/
function getplus($x=,$value=,$plus=close,$method= all){
Global $_GET,$_POST;
$array = array();
if($method==all){
$array[] = $_GET;$array[] = $_POST;}
elseif($method==get){$array[] = $_GET;}
elseif($method==post){$array[] = $_POST;}
$a = $_GET;
$i = 1;
$true = 0;
foreach($array as $k => $a){
foreach($a as $b = > $c){
if($b==$x){
$c = $value;
$true = 1;//Found it
$true2 = 1;
}
if($plus==close){
if($i==1){
$temp .= "?$b=$c";
}else{
$temp .= "&$b=$c";
}
}else{
if($i==1){
if($true2!=1){$temp .= "?$b=$c";}else{$temp.="?";unset($true2);}
}else{
if($true2!=1){$temp . = "&$b=$c";}else{unset($true2);}
}
}
$i++;
}
}
if($true= =0){
if (strpos($temp,"?")>0 || strpos($temp,"=")>0){
$temp .= "&$x=$ value";
}else{
$temp .= "?$x=$value";
}
}
elseif($true==1 && $plus!=close) {
if (strpos($temp,"?")>0 || strpos($temp,"=")>0){
$temp .= "&$x=$value";
}else{
$temp .= "?$x=$value";
}
}
return $temp;
}
?>

For example, originally
GET: ?method=1&a=1&b=2
POST: y=2007&m=03
Used

It will be displayed after
?method=1&a=1&b=2&y=2007&m=03&c=3
After using
🎜>?method=1&b=2&y=2007&m=03&a=3
Drag a=3 to the end
I use to combine it with javascript
Previous page
I still feel pretty good!
Maybe there are still bugs that haven’t been discovered yet!
I hope everyone will mention it more!

http://www.bkjia.com/PHPjc/508239.html

truehttp: //www.bkjia.com/PHPjc/508239.htmlTechArticleSometimes we need to retain GET and POST parameters to pass on the next page or other purposes! For convenience at work, I wrote this code! I hope you can communicate more! ? /* Programming...
Statement:
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