Home  >  Article  >  Backend Development  >  php post提交。有关问题

php post提交。有关问题

WBOY
WBOYOriginal
2016-06-13 10:18:21996browse

php post提交。问题
假如post提交:
user=name1&password1=123456&password2=123456
这样的连接 

我想name{num}  
num{}=1,2,3,4,5,6等等

这里的变量怎么写?
源码如下:

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php $domain = "www.xxxx.xxx";$port = 80;$uri = "/reg.php?cont=store_user";$refe = "http://www.xxxx.xxx/reg.php";$num=1;$data    ="lang=Chinese&username=like{$num}&password1=123456&password2=123456&mobile=&email=&srvid=1&textarea=%E6%8F%90%E7%A4%BA%EF%BC%9A%E8%AF%B7%E4%BB%94%E7%BB%86%E9%98%85%E8%AF%BB%E4%BB%A5%E4%B8%8B%E6%9D%A1%E6%AC%BE%EF%BC%8C%E5%86%8D%E6%B3%A8%E5%86%8C%E5%B8%90%E5%8F%B7%E3%80%82%E4%BD%BF%E7%94%A8%E6%9C%AC%E7%BD%91%E7%AB%99%E8%A1%A8%E7%A4%BA%E6%82%A8%E5%90%8C%E6%84%8F%E9%81%B5%E5%AE%88%E8%BF%99%E4%BA%9B%E6%9D%A1%E6%AC%BE%E5%92%8C%E6%9D%A1%E4%BB%B6%E3%80%82%E5%A6%82%E6%9E%9C%E6%82%A8%E4%B8%8D%E6%8E%A5%E5%8F%97%E8%BF%99%E4%BA%9B%E6%9D%A1%E6%AC%BE%EF%BC%88%E2%80%9C%E6%9D%A1%E6%AC%BE%E2%80%9D%EF%BC%89%EF%BC%8C%E8%AF%B7%E5%8B%BF%E6%B3%A8%E5%86%8C%E3%80%82&acceptterms=1&adduser=%E5%88%9B%E5%BB%BA%E8%B4%A6%E6%88%B7";$protocolstr = "POST {$uri} HTTP/1.1\nAccept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*\nReferer: {$refe}\r\nAccept-Language: zh-cn\nContent-Type:application/x-www-form-urlencoded\nAccept-Encoding: gzip, deflate\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; 360SE)\nHost: {$domain}\nContent-Length: 702\nConnection: Keep-Alive\nCache-Control: no-cache\nCookie: login_user=aabbcc02; PHPSESSID=hs23i9tguang96k7del3oafc64; lzstat_uv=2113815751356026816|2652038; lzstat_ss=2265145365_0_1335089150_2652038\n\n{$data}";for ($i=1; $i<100;$i++){    for(;$num<10;$num++)$sock = fsockopen($domain, $port, $errno, $errstr, 30);if (!$sock) die("$errstr ($errno)\n"); fputs($sock, $protocolstr);$headers = "";   while ($str = trim(fgets($sock, 4096)))     $headers .= "$str\n";      $body = "";   while (!feof($sock))     $body .= fgets($sock, 4096);   fclose($sock);   }echo "<h2>Response header:\n";   echo $headers;   echo "\n";      echo "<h2>Response body:</h2>\n";   echo $body;?>  


------解决方案--------------------
3楼被删??
写个文件初始内容为1,post之前读取文件取出数值$num,得到name.$num,post之后把$num加1再写入这个文件
------解决方案--------------------
//post之前
$filenum="num.txt";
$fnum=fopen($filenum,"r");
if(!$num=fgetc($fnum))
{$num=0;}
.......你的操作
//post之后
$filenum="num.txt";
$fnum=fopen($filenum,"r");
if(!$num=fgetc($fnum))
{$num=0;}
else
{$num=intval($num)++;
fclose($fnum);
$fnumw=fopen($filenum,"w");
fwrite(fnumw,strval($num));
fclose($filenum);
}
?>
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