|
|
|
รบกวนท่านผู้รู้น่อยคร้าบบบ คือผมทำหน้าตั้งกระทู้อยากให้ใส่ข้อมูลให้ครบถึงจะะตั้งได้อ่าคับ |
|
|
|
|
|
|
|
Code (PHP)
<?php require_once('Connections/member.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "1000,9000";
$MM_donotCheckaccess = "false";
// *** 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 == "") && false) {
$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;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmNew")) {
$insertSQL = sprintf("INSERT INTO webboard (Question, Details, Name) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['new'], "text"),
GetSQLValueString($_POST['detail'], "text"),
GetSQLValueString($_POST['name'], "text"));
mysql_select_db($database_member, $member);
$Result1 = mysql_query($insertSQL, $member) or die(mysql_error());
$insertGoTo = "Webboard.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_member, $member);
$query_insertnew = "SELECT * FROM webboard";
$insertnew = mysql_query($query_insertnew, $member) or die(mysql_error());
$row_insertnew = mysql_fetch_assoc($insertnew);
$totalRows_insertnew = mysql_num_rows($insertnew);
?><!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=iso-8859-1">
<title>Webboard</title>
<style type="text/css">
<!--
.style12 {font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; }
body {
background-image: url(images/bg_tree2.jpg);
margin-top: 0px;
margin-bottom: 50px;
margin-left: 100px;
}
.style39 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; }
.style18 {font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; }
-->
</style>
</head>
<body>
<p>
<?php
mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client=tis620");
mysql_query("SET character_set_connection=tis620");
?>
</p>
<p> </p>
<p> </p>
<div align="center"></div>
<table width="762" height="395" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<td width="762" height="395" align="left" valign="top" background="images/BGnewtopic.png"><div align="center">
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="frmNew" id="frmNew">
<p> </p>
<p align="left"> </p>
<p> </p>
<div align="left"></div>
<p> </p>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="88"><span class="style39">หัวข้อกระทู้</span></td>
<td width="512"><label> </label>
<div align="left">
<input name="new" type="text" id="new" size="70" maxlength="50" />
</div></td>
</tr>
<tr>
<td><span class="style39">รายละเอียด:</span></td>
<td><label> </label>
<div align="left">
<textarea name="detail" id="detail" cols="63" rows="5"></textarea>
</div></td>
</tr>
<tr>
<td><div align="center"><span class="style39"> ชื่อผู้ใช้:</span></div></td>
<td><label> </label>
<div align="left">
<label>
<input name="textfield"readonly=" type="text" id="textfield" value="<?php echo $_SESSION['MM_Username']; ?>" />
</label>
</div></td>
</tr>
</table>
<p><input type="submit" name="button" id="button" value="ตั้งกระทู้" />
<input type="reset" name="button2" id="button2" value="ยกเลิก" />
</p>
<p>
<input type="hidden" name="MM_insert" value="frmNew" />
<a href="Webboard.php" class="style12">ย้อนกลับ</a> </p>
</form>
</div></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($insertnew);
?>
ช่วยทีคับ คือตอนนี้ถ้าตั้งกระทู้ โดยไม่ใส่หัวข้อกระทู้ มันจะตั้งได้ อยากให้มันตั้งไม่ได้ต้องแก้ยังไงหรอคับ
Tag : PHP
|
|
|
|
|
|
Date :
2013-03-07 11:55:34 |
By :
bmza9999 |
View :
626 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณสำหรับข้อมูลดีๆคับท่าน Ex-[S]i[L]e[N]t นำไปปรับใช้ได้แล้วคับ
|
|
|
|
|
Date :
2013-03-07 13:01:57 |
By :
bmza9999 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|