📄 update.php
字号:
<?php require_once('Connections/vote.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_rsVote = "-1";
if (isset($_GET['vid'])) {
$colname_rsVote = (get_magic_quotes_gpc()) ? $_GET['vid'] : addslashes($_GET['vid']);
}
mysql_select_db($database_vote, $vote);
$query_rsVote = sprintf("SELECT * FROM view2 WHERE vote_id = %s", GetSQLValueString($colname_rsVote, "int"));
$rsVote = mysql_query($query_rsVote, $vote) or die(mysql_error());
$row_rsVote = mysql_fetch_assoc($rsVote);
$totalRows_rsVote = mysql_num_rows($rsVote);
?>
<?php
if ( isset ( $_POST["btnUpdate"] ) ) {
$items = $_POST["txtItems"];
$ids = $_POST["hidVoteItemIds"];
$n = count ( $items );
for ( $i = 0; $i < $n; $i++ ) {
$sql = sprintf ( "UPDATE votedetail SET vote_description='%s' WHERE voteitem_id=%d"
, $items[$i], $ids[$i] );
mysql_query ( $sql );
}
header ( "Location: admin.php" );
}
?>
<!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=gb2312" />
<title>编辑投票选项</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="98%" border="1" frame="below" rules="none">
<tr>
<td scope="col"><img src="images/logo.gif" width="160" height="33" /></td>
<td valign="bottom" scope="col"><a href="index.php">系统首页</a></td>
<td valign="bottom" scope="col"><a href="<?php echo $logoutAction ?>">注销</a></td>
<td align="right" valign="bottom" scope="col"><?php echo date("Y年n月j日"); ?> </td>
</tr>
</table>
<br />
当前位置:<a href="admin.php">后台管理</a> > 编辑选项
<form id="form1" name="form1" method="post" action="">
<table width="300" border="1" align="center" frame="" rules="none">
<tr>
<th colspan="2" bgcolor="#666666" class="title" scope="col"><?php echo $row_rsVote['vote_title']; ?></th>
</tr>
<tr>
<td width="93" height="26" align="right">类型:</td>
<td width="191" height="26"><?php echo $row_rsVote['vote_type']=="radio" ? "单选" : "多选"; ?></td>
</tr>
<?php do { ?>
<tr>
<td height="26" align="right">选项:</td>
<td height="26"><input name="txtItems[]" type="text" id="txtItems[]" value="<?php echo $row_rsVote['vote_description']; ?>" />
<input name="hidVoteItemIds[]" type="hidden" id="hidVoteItemIds[]" value="<?php echo $row_rsVote['voteitem_id']; ?>" /></td>
</tr>
<?php } while ($row_rsVote = mysql_fetch_assoc($rsVote)); ?>
<tr>
<td height="32" colspan="2" align="center"><input name="btnUpdate" type="submit" id="btnUpdate" value="更新" />
<input name="btnReset" type="reset" id="btnReset" value="重置" /></td>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($rsVote);
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -