|
|
|
ช่วยผมทีคับ เช็คค่าว่าง ให้แจ้งเมื่อมีค่าว่างอ่ะคับ ต้องเพิ่มตรงไหนคับ |
|
|
|
|
|
|
|
ประมาณนี้ป่าวครับที่ต้องการ
Code (PHP)
<?
$objConnect = mysql_connect("localhost","root","123") or die("Error Connect to Database");
$objDB = mysql_select_db("av_movierental");
mysql_query("SET NAMES UTF8");
if($_GET["Action"] == "Save")
{
if(($_POST["txtQuestion"]=='') || ($_POST["txtDetails"]=='') || ($_POST["txtName"]=='')){ //เช็คค่าว่าง
echo 'กรุณากรอกข้อมูลให้ครบ!!!';
}else{
//*** Insert Question ***//
$strSQL = "INSERT INTO webboard ";
$strSQL .="(CreateDate,Question,Details,Name) ";
$strSQL .="VALUES ";
$strSQL .="('".date("Y-m-d H:i:s")."','".$_POST["txtQuestion"]."','".$_POST["txtDetails"]."','".$_POST["txtName"]."') ";
$objQuery = mysql_query($strSQL);
header("location:Webboard.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>
<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
body {
background-image: url(img/bg-home1.jpg);
background-repeat: repeat;
background-attachment:fixed;
}
-->
</style>
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
</head>
<body>
<table width="1002" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th scope="col" width="1002" height="220"><img src="img/h1.gif" width="1006" height="230" align="top" /></th>
</tr>
<td> <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="39%"><div align="center">
<table id="Table_01" width="114" height="22" border="0" cellpadding="0" cellspacing="5">
<tr>
<th scope="col"><a href="index.php"><img src="img/img1.gif" width="200" height="49" border="0" /></a></th>
<th scope="col"><a href="detailshop.php"><img src="img/img2.gif" width="200" height="49" border="0" /></a></th>
<th scope="col"><a href="webboard.php"><img src="img/img3.gif" width="200" height="49" border="0" /></a></th>
<th scope="col"><a href="admin"><img src="img/img4.gif" width="200" height="49" border="0" /></a></th>
</tr>
</table>
</div></td>
</tr>
<tr>
<th scope="col"><table width="954" border="0" cellspacing="0" cellpadding="0">
<tr>
</tr>
<tr>
<th scope="col"><table width="1006" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="500" align="center" valign="top" bgcolor="#FFFFFF" scope="col"><p> </p>
<html>
<head>
<title>เว็บบอร์ด</title>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
</head>
<body>
<form action="NewQuestion.php?Action=Save" method="post" name="frmMain" id="frmMain">
<table width="621" border="1" cellpadding="1" cellspacing="1">
<tr>
<td>หัวข้อ</td>
<td><input name="txtQuestion" type="text" id="txtQuestion" value="" size="70"></td>
</tr>
<tr>
<td width="78">รายละเอียด</td>
<td><textarea name="txtDetails" cols="50" rows="5" id="txtDetails"></textarea></td>
</tr>
<tr>
<td width="78">ชื่อ</td>
<td width="647"><input name="txtName" type="text" id="txtName" value="" size="50"></td>
</tr>
</table>
<input name="btnSave" type="submit" id="btnSave" value="ตกลง">
</form>
</body>
</html>
<?
mysql_close($objConnect);
?>
<tr>
<th height="100" scope="col"><img src="img/f1.jpg" width="1006" height="100" /></th>
</tr>
</table></th>
</tr>
</table></th>
</tr>
</table>
<script type="text/javascript">
swfobject.registerObject("FlashID");
</script>
</body>
</html>
|
|
|
|
|
Date :
2012-08-31 10:46:06 |
By :
arm8957 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<script language="javascript">
function fncSubmit()
{
if(document.form1.txt1.value == "")
{
alert('Please input Input 1');
document.form1.txt1.focus();
return false;
}
if(document.form1.txt2.value == "")
{
alert('Please input Input 2');
document.form1.txt2.focus();
return false;
}
document.form1.submit();
}
</script>
<form action="page.cgi" method="post" name="form1" onSubmit="JavaScript:return fncSubmit();">
Input 1 <input name="txt1" type="text"><br>
Input 2 <input name="txt2" type="text"><br>
<input name="btnSubmit1" type="submit" value="Submit" >
</form>
</body>
</html>
ตรง <form> เพิ่ม onSubmit="JavaScript:return fncSubmit();"
|
|
|
|
|
Date :
2012-08-31 10:48:52 |
By :
pumin99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|