⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 add.php

📁 我们运用一个小的记事本
💻 PHP
字号:
<?php
session_start(); 
include 'include/config.php';
include 'include/para.php';
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>签写留言 - <?php echo $gb_name?></title>
<link href="include/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php include 'include/head.php';
if(session_is_registered('timer') && time() - $_SESSION['timer'] <$timejg){?>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="18" bgcolor="#FFFFFF">
  <tr> 
    <td><table width="98%" border="0" align="center" cellpadding="10" cellspacing="15" bgcolor="#EBF5FE">
        <tr> 
          <td align="center" valign="top" bgcolor="#FFFFFF"> 
            <?php 
		  echo "<img src=\"images/error.gif\"><br><font style=font-size:12pt;color=green>留言间隔太短,请".$timejg."秒后再留言……您还需等待:".abs($timejg-(time()-$_SESSION['timer']))."秒</font><br><a href=\"index.php\">如果浏览器没有自动返回,请点击此处返回</a>;";
			echo "<meta http-equiv=\"refresh\" content=\"3; url=index.php\">";
		  ?>
          </td>
        </tr>
      </table></td>
  </tr>
</table>
<?php }else{ 
if(empty($_POST['ac'])){
include 'include/randnum.php';
$s = new code();
$s->genimg(); 
?>
<form name="form1" method="post" action="<?php $_SERVER['PHP_SELF']?>" onSubmit="return FrontPage_Form1_Validator(this)">
  <table width="750" border="0" align="center" cellpadding="0" cellspacing="10" bgcolor="#FFFFFF">
    <tr>
      <td align="center">
		<table width="96%" border="0" cellpadding="0" cellspacing="15" bgcolor="#EBF5FE">
          <tr> 
            <td align="center" valign="top" bgcolor="#FFFFFF"> 
              <table width="100%" border="0" cellpadding="5" cellspacing="0" class="border2">
                <tr> 
                  <td height="50" colspan="2"> <table width="95%" border="0" cellspacing="2" cellpadding="0">
                      <tr> 
                        <td width="9%" align="center"><font color="#0066FF"><img src="images/i1.gif" width="36" height="36"></font></td>
                        <td width="91%" class="font16"><img src="images/add.gif" width="99" height="28"></td>
                      </tr>
                    </table></td>
                </tr>
                <tr> 
                  <td width="22%" align="right"><font color="#333333">昵称:</font></td>
                  <td width="78%"> <input name="username" type="text" id="username"> 
                    <font color="#999999">*</font></td>
                </tr>
                <tr> 
                  <td align="right"><font color="#333333">Email:</font></td>
                  <td><input name="email" type="text" id="email" size="50"></td>
                </tr>
                <tr> 
                  <td align="right"><font color="#333333">内容:</font></td>
                  <td> <textarea name="content" cols="60" rows="9" id="content"></textarea>
                    <font color="#999999">*<br>
                    <font color="#999999"><font color="#666666">提交之前请先按CTRL+V保存您的留言内容,以免程序出错而丢失!</font></font><font color="#666666"><br>
                    </font><font color="#999999"><font color="#999999"><font color="#666666"> 
                    </font></font><font color="#666666">留言内容最少5个字符!</font></font>                    </font></td>
                </tr>
                <tr>
                  <td align="right">悄悄话:</td>
                  <td height="50"><input name="ifqqh" type="checkbox" id="ifqqh" value="1">
                    <font color="#666666">(当选中时,此留言只有管理员可见)</font></td>
                </tr>
                <tr> 
                  <td align="right"><font color="#333333">验证码:</font></td>
                  <td height="50"> <input name="unum" type="text" id="unum" size="10"> 
                    <font color="#999999">*</font> <IMG SRC='<?php echo 'imcode.png?'.time();?>' WIDTH='50' HEIGHT='25' BORDER=0 ALT=''>				  </td>
                </tr>
                <tr> 
                  <td align="right"> <script language=JavaScript>
function FrontPage_Form1_Validator(theForm)
{
  if (theForm.username.value == "")
  {
    alert("请填写昵称!");
    theForm.username.focus();
    return (false);
  }
  if (theForm.username.value.length<3)
  {
    alert("昵称至少应为3个字符!");
    theForm.username.focus();
    return (false);
  }
  if(theForm.email.value!=""){
              var email1 = theForm.email.value;
              var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; 
              flag = pattern.test(email1); 
              if(!flag){
              alert("邮件地址格式不对!");
     theForm.email.focus();
           return false;}
  }

  if (theForm.content.value == "")
  {
    alert("留言内容不能空!");
    theForm.content.focus();
    return (false);
  }
  if (theForm.content.value.length<5)
  {
    alert("留言内容最少5个字符!");
    theForm.content.focus();
    return (false);
  }
  if (theForm.unum.value == "")
  {
    alert("请您输入验证码!");
    theForm.unum.focus();
    return (false);
  }
   return (true);
}
</script></td>
                  <td height="50" class="font14"> <input type="submit" name="Submit" value=" 发表留言 "> 
                    <input name="ac" type="hidden" id="ac" value="add">                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</form>
<?php }else{?>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="18" bgcolor="#FFFFFF">
  <tr> 
    <td><table width="98%" border="0" align="center" cellpadding="10" cellspacing="15" bgcolor="#EBF5FE">
        <tr> 
          <td align="center" bgcolor="#FFFFFF"> 
            <?php
	if(eregi('WIN',PHP_OS)) date_default_timezone_set('Asia/Shanghai');
		 $unum_temp=$_POST['unum'];
		 if($unum_temp==$_SESSION["code"]){
			$username=$_POST['username'];
			$email=$_POST['email'];
			$content=$_POST['content'];
			$userip=$_SERVER["REMOTE_ADDR"];
			$ifqqh=$_POST["ifqqh"];
			if(empty($ifqqh)) $ifqqh=0;
			$systime=date("Y-m-d H:i:s");
			//还原空格和回车
			$content=str_replace(" ","",$content);
			$content=str_replace(" ","",$content);
			$username=str_replace(" ","",$username);
			$username=str_replace(" ","",$username);
			if(!empty($content) and !empty($username)){
			$content=str_replace("'","‘",$content);
			$username=str_replace("'","‘",$username);
			$email=str_replace("'","‘",$email);
			$ifshow="";
			if(!empty($content)){
				$content=str_replace(" ","",$content);
				$content=ereg_replace("\n","<br>  ",ereg_replace(" ","&nbsp;",$content));
			}
			if($ifauditing==1){
			$ifshow=0;
			}else{
			$ifshow=1;
			}
			//还原结束
			$sql="insert into ".TABLE_PREFIX."guestbook(username,email,content,userip,systime,ifshow,ifqqh)values('".$username."','".$email."','".$content."','".$userip."','".$systime."',".$ifshow.",".$ifqqh.")";
			//echo $sql;
				if(($db->insert($sql))>0){
					$_SESSION['timer']=time();
					echo "<img src=\"images/success.gif\"> <font style=font-size:12pt;color=green>留言发表成功,请稍候……</font><br><a href=index.php>如果浏览器没有自动返回,请点击此处返回</a>;";
					echo "<meta http-equiv=\"refresh\" content=\"3; url=index.php\">";
				}else{
					echo "<font color=#996633>对不起,留言失败!信息中可能含有敏感字符或不利于程序运行的特殊字符……</font>";
					echo "<meta http-equiv=\"refresh\" content=\"5; url=".$_SERVER['PHP_SELF']."\">";
				}
			}else{
				echo "<img src=\"images/error.gif\"><br><font style=font-size:12pt;color=green>您的昵称或留言内容不能是无效字符,请重新填写!系统正在为您返回……</font><br><a href=index.php>如果浏览器没有自动返回,请点击此处返回</a>;";
				echo "<meta http-equiv=\"refresh\" content=\"3; url=".$_SERVER["HTTP_REFERER"]."\">";
			}
		}else{
			echo "<script language=\"javascript\">alert('对不起,验证码不正确,请重新输入……');history.back()</script>";
		}
?>
          </td>
        </tr>
      </table></td>
  </tr>
</table>
<?php }
}?>
<?php include 'include/foot.php';?>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -