一个简单地留言板的初始模板:
主页menu.html如下:
1 <html><head>
2 <title>简单的留言板</title>
3 </head><body>
4 <p><h3 align = "center"><font color = "red">欢迎来的我的简单留言板,请登录或者注册。</font></h3></p>
5 <form action = "log.php" method = "post">
6 Username:<input type = "text" name = "username" />
7 Passwd:<input type = "password" name = "password" maxlength = "6" /><br>
8 <input type = "submit" /> <input type = "reset" /><br>
9 </body></html>
10
~
log.php文件内容如下:
1 <?php
2 header("content-type:text/html; charset=UTF-8");
3 print "Your name is :".$_POST["username"]."<p>";
4 print "Your code is :".$_POST["password"]."<p>";
5 if($_POST["username"] == NULL){
6 print "输入错误,用户名为空。";
7 exit;
8 }
9 if($_POST["password"] == NULL){
10 print "输入错误,密码为空。";
11 exit;
12 }
13 $file = fopen("info.txt","rb");
14 while(!feof($file)){
15 $str = fgetss($file);
16 $str = substr($str,0,strlen($str)-1);
17 $array = explode("*",$str);
18 if(!strcmp($array[0],$_POST["username"]) && !strcmp($array[1],$_POST["password"])){
19 print "欢迎进入我的简单留言板。<p>";
20 break;
21 }
22 }
未完待续。。。