Home > php教程 > php手册 > body text

PHP加入数据程序的具体实现方法

WBOY
Release: 2016-06-13 11:09:27
Original
1017 people have browsed it

PHP加入数据程序代码:

  1. $datedate=date(”Y-m-d H:i:s”);  
  2. //取得系统时间  
  3. $ip = $HTTP_SERVER_VARS[REMOTE_ADDR];  
  4.  //取得发言的IP地址  
  5. $text=encode($gb_text);  
  6. //去掉留言内容后面的空格.  
  7. $fp=fopen(”gb.dat”,”a”);  
  8. //以只写模式打开gb.dat文本文件,文件指针指向文件尾部.  
  9. $str=$ip.”|”.$date.”|”.$gb_name.”|”.$gb_email.”|”.$gb_home.”|”.$face.”|”.$gb_qq.”|”.$head.”|”.$text.”|”.$reply.”n”;   
  10. //将所有留言的数据赋予变量$str,”|”的目的是用来今后作数据分割时的数据间隔符号。  
  11. fwrite($fp,$str);  
  12. //将数据写入文件  
  13. fclose($fp);  
  14. //关闭文件  
  15. showmessage(”留言成功!”,”index.php”,”3″);  
  16. //留言成功,3秒后自动返回主界面。 


PHP加入数据程序的代码中的$gb_name 、$gb_email、$gb_home、$face、$gb_qq、$head、$gb_text、$reply是由发言表单传过来的数据。
 


source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!