& lt?服務器端編程語言(Professional Hypertext Preprocessor的縮寫)if($ _ REQUEST[' action ']= ' do '){提取($ _ POST);$r=fop" />
& ltmeta http-equiv = " Content-Type " Content = " text/html;charset=utf-8" />
& lt?服務器端編程語言(Professional Hypertext Preprocessor的縮寫)
if($ _ REQUEST[' action ']= ' do '){
提取($ _ POST);
$r=fopen('post.txt ',' a+');
$str=iconv('utf-8 ',' gb2312 ',$T1。' '.$R1。' '.$T2。' '.$S1。“& ltbr >;);
fwrite($r,$ str);
回聲' & lt腳本& gtlocation . href = " index . PHP ";& lt/script & gt;';
}
if(file _ exists(' post . txt '){
$ result = explode(" & lt;br >;,substr(iconv('gb2312 ',' utf-8 ',file_get_contents('post.txt '),0,-4));
foreach ($result as $value){
$arr=explode(",$ value);
$ postarr[]= $ arr;
}
}
& gt
& lt?php if(count($result)):?& gt
& lt?php foreach ($postarr as $value):?& gt
名稱:& lt?PHP echo $ value[0];?& gt& ltbr & gt
性:& lt?PHP if($ value[1])echo ' female ';else echo男’;?& gt& ltbr & gt
電子郵件:& lt?PHP echo $ value[2];?& gt& ltbr & gt
消息:& lt?PHP echo $ value[3];?& gt& ltbr & gt
& lthr & gt
& lt?php endforeach?& gt
& lt?php else:?& gt
沒有消息。
& lt?php endif?& gt
& ltform method = " post " action = " index . PHP?action = do " & gt
& ltp & gt您的姓名:& ltinput type = " text " name = " t 1 "/& gt;& lt/p & gt;
& ltp & gt性:
男& ltinput type = " radio " value = " 0 " name = " r 1 "/>
女性& ltinput type = " radio " name = " r 1 " value = " 1 "/>& lt/p & gt;
& ltp & gt您的電子郵件:& ltinput type = " text " name = " T2 " size = " 35 "/& gt;& lt/p & gt;
& ltp & gt您的消息:& lt/p & gt;
& ltp & gt& lttextarea rows = " 16 " name = " s 1 " cols = " 44 " >& lt/textarea & gt;& lt/p & gt;
& ltp & gt& ltinput type = " Submit " value = " Submit " name = " b 1 "/>
& ltinput type = " Reset " value = " Reset " name = " B2 "/& gt;& lt/p & gt;
& lt/form & gt;
& lt/body & gt;
& lt/html & gt;