Posts Tagged ‘資工’

session_start();
$captcha_message = "請輸入驗證碼";
if (isset($_POST["captcha"]) && trim(strtolower($_POST['captcha'])) != $_SESSION['captcha']) {
        $captcha_message = "驗證碼錯誤!!";
}
=======
<--img src="captcha/captcha.php" id="captcha" />
<--input type="text" name="captcha" id="captcha-form" autocomplete="off" />
<--?php echo $captcha_message;?>

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

<!--?php
if (isset($_POST["Submit"]))
{
	//讀入表單參數
	$email = $_POST["ST-EMail"];
 	$message = $_POST["ST-Message"];
	$vtime = date("Y-m-d H:i:s");
	//寫入資料庫
	$link = mysql_connect("localhost", "root", "");
	mysql_query("SET NAMES 'UTF8'");
    mysql_select_db("sss");
    $query = "INSERT INTO guestbook(email, message, vtime) VALUES ('$email','$message','$vtime')";
    $result = mysql_query($query);
    mysql_close($link);
}
 
?-->
 
<form action="midterm.php" method="post">
<table border="1" width="100%">
<tbody>
<tr>
<td colspan="2">請問您有何建議</td>
</tr>
<tr>
<td colspan="2">EMail:
<input type="text" name="ST-EMail" /></td>
</tr>
<tr>
<td colspan="2">留言:
<input type="text" name="ST-Message" /></td>
</tr>
<tr>
<td></td>
<td width="20%"> 
<input type="submit" name="Submit" value="送出留言" /></td>
</tr>
</tbody></table>
</form>
<h1>留言內容</h1>
<hr />
<?php
//從資料庫讀出投票資料
	$link = mysql_connect("localhost", "root", "");
	mysql_query("SET NAMES 'UTF8'");
    mysql_select_db("sss");
 
    $query = "SELECT COUNT(*) FROM guestbook";
	$result = mysql_query($query);
	$total_records	 = mysql_fetch_row($result);
 
echo '
 
總留言數:'.$total_records[0].' 
 
';
?>
<hr />
<?php
$query="SELECT * FROM guestbook ORDER BY vtime DESC LIMIT 20";
$result=mysql_query($query) or die(mysql_error());
$num_rows = mysql_num_rows($result);
 
?>
 
";
}
?&gt;
<table border="1" width="100%" id="table1">
<tbody>
<tr>
<td>GID</td>
<td>EMail</td>
<td>Message</td>
<td>Visit Time</td>
</tr>
<!--?php
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
print "
<tr-->
<tr>
<td>".$row["gid"]."</td>
<td>".$row["email"]."</td>
<td>".$row['message']."</td>
<td>".$row['vtime']."</td>
</tr>
</tbody></table>
<!--?php
mysql_close($link);
?-->

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

<?php
if (isset($_POST["Submit"]))
{
	//讀入表單參數
	$email = $_POST["ST-EMail"];
	$approval = $_POST["ST-Approval"];
 	$message = $_POST["ST-Message"];
	$vtime = date("Y-m-d H:i:s");
	//寫入資料庫
	$link = mysql_connect("localhost", "root", "");
	mysql_query("SET NAMES 'UTF8'");
    mysql_select_db("stvote");
    $query = "INSERT INTO vote_table(email, approval, message, vtime) VALUES ('$email','$approval', '$message','$vtime')";
    $result = mysql_query($query);
    mysql_close($link);
 
	//重新導向網頁
	header('Location: ex7-list.php');
  	exit;
}
 
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>喜歡或反對伏冒的投票系統</title>
</head>
 
<body>
<form action="ex7-vote.php" method="post">
<table width="100%" border="1">
  <tr>
    <td colspan="2">請問您對伏冒藥的看法</td>
  </tr>
  <tr>
    <td colspan="2">EMail:<input name="ST-EMail" type="text" /></td>
  </tr>
  <tr>
    <td>&nbsp;<input name="ST-Approval" type="radio" value="yes" />支持反伏冒</td>
    <td>&nbsp;<input name="ST-Approval" type="radio" value="no" />志願喝伏冒</td>
  </tr>
  <tr>
    <td colspan="2">理由:<input name="ST-Message" type="text" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;<input name="Submit" type="submit" value="送出投票單" /></td>
  </tr>
</table>
</form>
</body>
</html>

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>伏冒投票結果</title>
</head>
 
<body>
<h1>謝謝您參與本次伏冒投票!以下是投票結果</h1>
<hr />
<?php
//從資料庫讀出投票資料
	$link = mysql_connect("localhost", "root", "");
	mysql_query("SET NAMES 'UTF8'");
    mysql_select_db("stvote");
 
    $query = "SELECT COUNT(*) FROM vote_table";
	$result = mysql_query($query);
	$totalVote = mysql_fetch_row($result);
 
	$query = "SELECT COUNT(*) FROM vote_table WHERE approval='yes' ";
	$result = mysql_query($query);
    $yesVote =  mysql_fetch_row($result);
 
	$query = "SELECT COUNT(*) FROM vote_table WHERE approval<>'yes' ";
	$result = mysql_query($query);
    $noVote =  mysql_fetch_row($result);
 
echo '<p>總投票數:'.$totalVote[0].' 支持反伏冒數:'.$yesVote[0].' 願意喝伏冒數:'.$noVote[0].' </p>';
?>
<hr />
<?php
$query="SELECT * FROM vote_table ORDER BY vtime DESC LIMIT 20";
$result=mysql_query($query) or die(mysql_error());
$num_rows = mysql_num_rows($result);
 
?>
 
<table border="1" width="100%" id="table1">
	<tr>
		<td>VID</td>
		<td>EMail</td>
		<td>Approval</td>
        <td>Message</td>
		<td>Vote Time</td>
	</tr>
<?php
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
print "
	<tr>
		<td>".$row["vid"]."</td>
		<td>".$row["email"]."</td>
		<td>".$row["approval"]."</td>
		<td>".$row['message']."</td>
		<td>".$row['vtime']."</td>
	</tr>
";
}
?>
</table>
 
 
<?php
mysql_close($link);
?>
</body>
</html>

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

CREATE TABLE IF NOT EXISTS `vote_table` (
  `vid` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(100) NOT NULL,
  `approval` varchar(10) NOT NULL,
  `message` varchar(2000) NOT NULL,
  `vtime` datetime NOT NULL,
  PRIMARY KEY (`vid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci AUTO_INCREMENT=5 ;
 
--
-- 轉存資料表中的資料 `vote_table`
--
 
INSERT INTO `vote_table` (`vid`, `email`, `approval`, `message`, `vtime`) VALUES
(1, 'htchu@asia.edu.tw', '贊成', '好', '2014-04-01 08:14:11'),
(2, 'htchu@asia.edu.tw', '贊成', '好好好', '2014-04-01 08:15:31'),
(3, 'aaa@asia.edu.tw', '贊成', '好好好好好好', '2014-04-01 09:10:14'),
(4, 'htchu2@asia.edu.tw', '反對', '不好', '2014-04-01 11:09:36');

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , , ,