|
|
|
ช่วยดู code ให้หน่อยค่ะ ที่ function fncSubmit() หน้ากรอกข้อมูล แล้วถ้าไม่กรอกข้อมูลลงไปในช่องให้ alert ข้อความทางหน้าจอ แต่ลองทำดูแล้วมันไม่แจ้งเตือนค่ะ ช่วยหน่อยนะคะ |
|
|
|
|
|
|
|
add.php
Code
<?
session_start();
if($_SESSION['USER_ID'] == "")
{
//echo"<body onload=\"window.alert('Please Login')\">";
//echo'<meta http-equiv="refresh" content="0; url=login.php">';
//exit();
}
include("connect.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=utf-8" />
<title>เพิ่มข้อมูลส่วนตัว</title>
<style type="text/css">
<!--
body {
background-image: url();
background-color: #FFFFFF;
}
a {
font-family: Geneva, Arial, Helvetica, sans-serif;
}
a:visited {
color: #FFFFFF;
text-decoration: none;
}
a:active {
color: #66FFFF;
text-decoration: none;
}
a:hover {
color: #66FFFF;
text-decoration: underline;
}
a:link {
text-decoration: none;
color: #000000;
}
.style110 {
font-size: 12px;
font-weight: bold;
}
.style117 {font-size: 12px; font-weight: bold; color: #CCFFFF; }
.style123 {
font-size: 13px;
font-weight: bold;
color: #CCFFFF;
font-style: italic;
}
.style124 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 11px; color: #FFFFFF; }
.style7 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; font-weight: bold; }
.style12 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 13px; color: #000000; font-weight: bold; }
.style129 {color: #FF0000; font-size: 16px; }
.style131 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 11px; color: #000000; font-weight: bold; }
.style132 {font-weight: bold; color: #CCFFFF; font-size: 11px;}
.style137 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 11px; color: #FF6633; font-weight: bold; }
.style138 {color: #FFFFFF}
-->
</style>
<script language="JavaScript" src="sf/mm_menu.js"></script>
<script type="text/javascript">
function fncSubmit()
{
if(document.form1.txname.value == "")
{
alert('กรุณากรอกชื่อ');
document.form1.txname.focus();
return false;
}
if(document.form1.txlname.value == "")
{
alert('กรุณากรอกนามสกุล');
document.form1.txlname.focus();
return false;
}
if(document.form1.txuse.value == "")
{
alert('กรุณากรอก Username');
document.form1.txuse.focus();
return false;
}
if(document.form1.txpass.value == "")
{
alert('กรุณากรอก Password');
document.form1.txpass.focus();
return false;
}
if(document.form1.sex.value == "")
{
alert('กรุณาเลือกเพศ');
document.form1.sex.focus();
return false;
}
if(document.form1.txmail.value == "")
{
alert('กรุณากรอก E-mail');
document.form1.txmail.focus();
return false;
}
if(document.form1.txname.value != "" && document.form1.txlname.value != "" && document.form1.txuser.value != "" && document.form1.txpass.value != "" && document.form1.sex.value != "" && document.form1.txmail.value != "") //ตัวแปรที่มีดอกจันทร์สีแดงทั้งหมด
{
return true;
}
document.form1.submit();
}
</script>
</head>
<? include("session_id.php");?>
<body>
<script language="JavaScript1.2">mmLoadMenus();</script>
<table width="749" border="2" align="center" cellpadding="1" cellspacing="2" bordercolor="#0066FF">
<tr>
<th height="194" colspan="3" align="left" valign="top" scope="col"><img src="Img/head2.jpg" width="737" height="195" /></th>
</tr>
<tr bordercolor="#FFFFFF">
<th width="737" height="477" colspan="3" align="center" valign="top" scope="col"><table width="737" border="1" cellspacing="1" bordercolor="#0066FF">
<tr bgcolor="#0033CC">
<th width="21" height="29" align="right" valign="middle" class="style124" scope="col"><a href="./main.php"><img src="Img/main.jpg" width="20" height="21" border="0" align="absmiddle" /></a></th>
<th width="46" align="left" valign="middle" bgcolor="#0033FF" class="style124" scope="col"> <a href="./main.php">หน้าหลัก</a></th>
<th width="21" align="right" valign="middle" class="style124" scope="col"><a href="./test.php"><img src="Img/images (5).jpg" width="20" height="21" border="0" align="absmiddle" /></a></th>
<th width="52" align="left" valign="middle" bgcolor="#0033FF" class="style124" scope="col"><a href="./test.php">ตรวจสอบ</a></th>
<th width="21" align="right" valign="middle" class="style124" scope="col"><a href="./report.php"><img src="Img/report.jpg" width="20" height="21" border="0" align="absmiddle" /></a></th>
<th width="46" align="left" valign="middle" bgcolor="#0033FF" class="style124" scope="col"><a href="./report.php">รายงาน</a></th>
<th width="21" align="right" valign="middle" class="style124" scope="col"><a href="./logout.php"></a><a href="./admin.php"><img src="Img/images.jpg" width="20" height="21" border="0" align="absmiddle" /></a></th>
<th width="60" align="left" valign="middle" class="style110" scope="col"><span class="style124"><a href="./admin.php">ผู้ดูแลระบบ</a></span></th>
<th width="21" align="right" valign="middle" class="style110" scope="col"><a href="./logout.php"><img src="Img/images (6).jpg" width="20" height="21" border="0" align="absmiddle" /></a></th>
<th width="72" align="left" valign="middle" class="style110" scope="col"><a href="./logout.php" class="style124"></a><a href="./logout.php" class="style124" onclick="return confirm('ต้องการออกจากระบบ หรือไม่');">ออกจากระบบ</a></th>
<th width="298" align="center" valign="middle" class="style124" scope="col"><strong>ยินดีต้อนรับ</strong> : <span class="style137"><span class="style138">"</span>
<?=$_SESSION['USER_NAME']?>
<span class="style138">"</span></span></th>
</tr>
</table>
<table width="737" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="736" height="25" align="left" scope="col"><img src="Img/bg1.jpg" width="737" height="3" /></th>
</tr>
</table>
<table width="571" height="394" border="2" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" >
<tr bgcolor="#FFFFFF">
<th width="567" height="382" align="left" valign="top" class="style7" scope="col"><form id="form1" name="form1" method="post" action="addadmin.php">
<table width="568" border="1" cellpadding="0" cellspacing="1" bordercolor="#00CCFF" >
<tr bordercolor="#66FFFF" bgcolor="#33CCFF">
<th height="34" colspan="3" scope="col"> </th>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<th width="138" height="67" scope="col"> </th>
<th width="117" align="right" scope="col"><img src="Img/edit.jpg" width="117" height="67" /></th>
<th width="303" align="left" class="style12" scope="col">เพิ่มข้อมูลส่วนตัว</th>
</tr>
</table>
<table width="568" border="1" cellpadding="0" cellspacing="0" bordercolor="#00FFFF" >
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<th width="196" height="29" align="right" valign="middle" class="style7" scope="col"><p> </p>
<p>ชื่อ</p></th>
<th width="9" align="left" valign="middle" scope="col"><p> </p>
<p>:</p></th>
<th colspan="2" align="left" valign="middle" scope="col"><label><br />
<br />
<input name="txname" type="text" id="txname" />
<span class="style129">*</span></label></th>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<th height="35" align="right" valign="middle" scope="col"><span class="style7">นามสกุล</span></th>
<th height="35" align="left" valign="middle" scope="col">:</th>
<th height="35" colspan="2" align="left" valign="middle" scope="col"><label>
<input name="txlname" type="text" id="txlname" />
<span class="style129">*</span></label></th>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<th height="32" align="right" valign="middle" scope="col">Username</th>
<th height="32" align="left" valign="middle" scope="col">:</th>
<th height="32" colspan="2" align="left" valign="middle" scope="col"><label>
<input name="txuse" type="text" id="txuse" />
<span class="style129">*</span></label></th>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<th height="35" align="right" valign="middle" scope="col">Password</th>
<th height="35" align="left" valign="middle" scope="col">:</th>
<th height="35" colspan="2" align="left" valign="middle" scope="col"><label>
<input name="txpass" type="password" id="txpass" size="21" />
<span class="style129">* <a href="./changepass.php" class="style131"></a></span></label></th>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<th height="31" align="right" valign="middle" class="style7" scope="col">เพศ</th>
<th height="31" align="left" valign="middle" scope="col">:</th>
<th height="31" colspan="2" align="left" valign="middle" scope="col"><label>
<select name="sex" id="sex" >
<?
if($resu[SEX]=="M"){
?>
<option value="">เลือก</option>
<option value="M">ชาย</option>
<option value="F">หญิง</option>
<? }else{?>
<option value="">เลือก</option>
<option value="F">หญิง</option>
<option value="M">ชาย</option>
<? }?>
</select>
<span class="style129">*</span></label></th>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<th height="40" align="right" valign="middle" class="style7" scope="col">E-mail</th>
<th height="40" align="left" valign="middle" scope="col">:</th>
<th height="40" colspan="2" align="left" valign="middle" scope="col"><label>
<input name="txmail" type="text" id="txmail" />
<span class="style129">*</span></label></th>
</tr>
<tr valign="bottom" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<th height="17" colspan="4" align="right" bgcolor="#FFFFFF" scope="col"><label></label></th>
</tr>
<tr bordercolor="#33CCFF" bgcolor="#99FFFF">
<th height="32" colspan="4" align="center" valign="middle" bgcolor="#33CCFF" scope="col"><input name="s" type="submit" class="style7" id="s" value="ยืนยันข้อมูล" />
<input name="Reset" type="reset" class="style7" value="ยกเลิก" /></th>
</tr>
</table>
</form>
</tr>
</table>
<table width="737" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="727" height="20" align="right" valign="top" bgcolor="#0033CC" class="style132" scope="col">ระบบติดตามการทำงานของเครื่องแม่ข่ายเว็บ</th>
<th width="10" rowspan="2" align="right" valign="top" bgcolor="#0033CC" class="style117" scope="col"> </th>
</tr>
<tr>
<th height="16" align="right" valign="top" bgcolor="#0033CC" class="style123" scope="col">Web Server Monitor System</th>
</tr>
</table> </th>
</tr>
</table>
</body>
</html>
addadmin.php
Code (PHP)
<html>
<head>
<title>SAVE_ADMIN</title>
</head>
<body>
<?php
include"connect.php";
//if($add){
$SQL = "INSERT INTO admin (USER_ID,USER_NAME,USER_PASS,ADMIN_NAME,ADMIN_LNAME,SEX,E_MAIL) VALUES
(null,'$txuse','$txpass','$txname','$txlname','$sex','$txmail')";
$objQuery = mysql_query($SQL);
if($objQuery){
//if(mysql_query($SQL)){
echo "<meta http-equiv='refresh' content='0; url=admin.php '>";
}
//}
else
{
echo "Error Save [".$SQL."]";
}
?>
</body>
</html>
Tag : PHP
|
|
|
|
|
|
Date :
2012-03-28 21:12:50 |
By :
Bahsang |
View :
1681 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เปลี่ยน
<form id="form1" name="form1" method="post" action="addadmin.php" onSubmit="JavaScript:return fncSubmit();">
|
|
|
|
|
Date :
2012-03-29 09:26:59 |
By :
pumin99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำด้ายแล้วค๊า า ขอบคุนมาก ๆน๊า ค๊า าที่ช่วย...>__<"
|
|
|
|
|
Date :
2012-03-29 11:35:25 |
By :
Bahsang |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|