[982]PHP網站開發 進階應用技巧
<?php
$root_pass="12345"; //資料庫root密碼
$db_name="test"; //資料庫名稱
/* 連資料庫檢查 */
$link=mysql_connect("localhost","root",$root_pass); //資料庫連線
mysql_select_db("test");
mysql_query("SET NAMES 'utf8'"); //設定語系
error_reporting(0);
$today=date("Y-m-d");
$sql="update `counter` set `counter`=`counter`+1 where `day`='$today'";
$result=mysql_query($sql);
$n=mysql_affected_rows($result);
if(empty($n)){
$sql="insert into `counter` (`day`,`counter`) values(now(),1000)";
mysql_query($sql);
}
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>圖形認證</title>
</head>
<body>
<div style="background-color:#FFFF99;border:1px dotted;padding:20px;width:300px;">
<img src="counter.php">
<img src="counter.php?op=all">
<form action="show.php" method="post">
<textarea name="content" cols=20><?php echo $_SESSION['content']; ?></textarea>
<p>請輸入下方圖上文字:<input type="text" name="key"><input type="submit" value="送出"></p>
<img src="pic.php">
</form>
<div>
</body>
</html>