|
|
|
ช่วยดู Code PHP ให้หน่อยครับ เพิ่มข้อมูลเข้าฐานข้อมูลไม่ได้ |
|
|
|
|
|
|
|
Form รับค่า add_em01.php
Code
<?
/*session_start();
if($_SESSION['user_number'] == "")
{
echo "</br></br></br></br></br></br></br></br></br></br></br>
<center><b><font color='red'>กรุณาล็อคอินเข้าสู่ระบบ !</font></b></center>";
echo "<center><b></br>กลับสู่<a href='login.php'> หน้าล็อคอิน</a></b></center>";
exit();
}
if($_SESSION['status'] != "Admin")
{
echo "<center><b></br></br>เฉพาะผู้ดูแลระบบเท่านั้น !</b></center>";
echo "<center><b></br>กลับสู่<a href='login.php'> หน้าล็อคอิน</a></b></center>";
exit();
} */
include("config/config.php");
$strSQL = "SELECT * FROM employee WHERE user_number = '".$_SESSION['user_number']."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
?>
<html>
<head>
<title>Suleephan Garment</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body bgcolor="#b4b4b4"></br></br></br>
<form method="post" action="add_em02.php">
<table align="center" background="picture/bg.jpg" border="0" width="1000" height="140">
<tr>
<td colspan="10" height="140" background="picture/header.jpg"></td>
</tr>
</table>
<table align="center" background="picture/bg.jpg" border="0" width="1000">
<tr>
<td height="138"><img src="picture/bottom_employ.png"></td>
</tr>
<tr>
<td width="380"></td>
<td width="110"><b>รหัสผู้ใช้</td>
<td><input type="hidden" name="user_number"></td>
</tr>
<tr>
<td width="380"></td>
<td><b>ชื่อผู้ใช้</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td width="380"></td>
<td><b>รหัสผ่าน</td>
<td><input type="password" name="password_crpt"></td>
</tr>
<tr>
<td width="380"></td>
<td><b>ยืนยันรหัสผ่าน</td>
<td><input type="password" name="conpassword"></td>
</tr>
<tr>
<td width="380"></td>
<td><b>ชื่อ</td>
<td><input type="text" name="employee_name"></td>
</tr>
<tr>
<td width="380"></td>
<td><b>สกุล</td>
<td><input type="text" name="employee_surname"></td>
</tr>
<tr>
<td width="380"></td>
<td><b>อีเมล์</td>
<td><input type="text" name="employee_email"></td>
</tr>
<tr>
<td width="380"></td>
<td><b>เบอร์ติดต่อ</td>
<td><input type="text" name="employee_tel"></td>
</tr>
<tr>
<td width="380"></td>
<td><b>ที่อยู่</td>
<td><input type="text" name="employee_address"></td>
</tr>
<tr>
<td width="380"></td>
<td><b>สถานะ</td>
<td><select name="statuslist">
<option>-- เลือกสถานะ --
<option value="01">Admin
<option value="02">User
<option value="03">Owner</td>
</tr>
<tr>
<td colspan="10"></br><center>
<center><input type="submit" name="save" value=" บันทึกข้อมูล "></center></br>
<input type="image" name="save" value="submit" src="picture/bottom_save.png" width="120" >
<a href="admin_page.php"><img src="picture/bottom_return.png" width="120"></a></center></td>
</tr>
</table>
</body>
</html>
SQL add_em02.php
Code
<?
/*session_start();
if($_SESSION['user_number'] == "")
{
echo "</br></br></br></br></br></br></br></br></br></br></br>
<center><b><font color='red'>กรุณาล็อคอินเข้าสู่ระบบ !</font></b></center>";
echo "<center><b></br>กลับสู่<a href='login.php'> หน้าล็อคอิน</a></b></center>";
exit();
}
if($_SESSION['status'] != "Admin")
{
echo "<center><b></br></br>เฉพาะผู้ดูแลระบบเท่านั้น !</b></center>";
echo "<center><b></br>กลับสู่<a href='login.php'> หน้าล็อคอิน</a></b></center>";
exit();
} */
include("config/config.php");
$user_number=$_POST["user_number"];
$username=$_POST["username"];
$password_crpt=$_POST["password_crpt"];
$conpassword=$_POST["conpassword"];
//$md5=md5($_POST["Password"]);
$employee_name=$_POST["employee_name"];
$employee_surname=$_POST["employee_surname"];
$employee_email=$_POST["employee_email"];
$employee_tel=$_POST["employee_tel"];
$employee_address=$_POST["employee_address"];
$status=$_POST["statuslist"];
if(trim($_POST["username"]) == "")
{
echo "</br></br></br></br></br></br></br></br></br></br></br></br>";
echo "<center><font color='red'><b>กรุณาระบุชื่อผู้ใช้ !</b></font></center>";
echo "</br><center><a href='add_em01.php'><img src='picture/bottom_em_return.png' width='150'></a></center>";
exit();
}
if(trim($_POST["password_crpt"]) == "")
{
echo "</br></br></br></br></br></br></br></br></br></br></br></br>";
echo "<center>"."<font color='red'><b>กรุณาระบุรหัสผ่าน !</b></font>";
echo "</br></br><center><a href='add_em01.php'><img src='picture/bottom_em_return.png' width='150'></a></center>";
exit();
}
if(trim($_POST["conpassword"]) == "")
{
echo "</br></br></br></br></br></br></br></br></br></br></br></br>";
echo "<center>"."<font color='red'><b>กรุณายืนยันรหัสผ่าน !</b></font>";
echo "</br></br><center><a href='add_em01.php'><img src='picture/bottom_em_return.png' width='150'></a></center>";
exit();
}
if($_POST["password_crpt"] != $_POST["conpassword"])
{
echo "</br></br></br></br></br></br></br></br></br></br></br></br>";
echo "<center>"."<font color='red'><b>รหัสผ่านไม่ตรงกัน !</b></font></center>";
echo "</br></br><center><a href='add_em01.php'><img src='picture/bottom_em_return.png' width='150'></a></center>";
exit();
}
if(trim($_POST["employee_name"]) == "")
{
echo "</br></br></br></br></br></br></br></br></br></br></br></br>";
echo "<center>"."<font color='red'><b>กรุณาระบุชื่อ !</b></font>";
echo "</br></br><center><a href='add_em01.php'><img src='picture/bottom_em_return.png' width='150'></a></center>";
exit();
}
if(trim($_POST["employee_surname"]) == "")
{
echo "</br></br></br></br></br></br></br></br></br></br></br></br>";
echo "<center>"."<font color='red'><b>กรุณาระบุสกุล !</b></font>";
echo "</br></br><center><a href='add_em01.php'><img src='picture/bottom_em_return.png' width='150'></a></center>";
exit();
}
if(trim($_POST["employee_email"]) == "")
{
echo "</br></br></br></br></br></br></br></br></br></br></br></br>";
echo "<center>"."<font color='red'><b>กรุณาระบุ Email !</b></font>";
echo "</br></br><center><a href='add_em01.php'><img src='picture/bottom_em_return.png' width='150'></a></center>";
exit();
}
if(trim($_POST["employee_tel"]) == "")
{
echo "</br></br></br></br></br></br></br></br></br></br></br></br>";
echo "<center>"."<font color='red'><b>กรุณาระบุ Tel !</b></font>";
echo "</br></br><center><a href='add_em01.php'><img src='picture/bottom_em_return.png' width='150'></a></center>";
exit();
}
if(trim($_POST["employee_address"]) == "")
{
echo "</br></br></br></br></br></br></br></br></br></br></br></br>";
echo "<center>"."<font color='red'><b>กรุณาระบุ Address !</b></font>";
echo "</br></br><center><a href='add_em01.php'><img src='picture/bottom_em_return.png' width='150'></a></center>";
exit();
}
mysql_query("SET NAMES UTF8");
$sql = " insert into employee user_number,username,password_crpt,employee_name,employee_surname,employee_email,employee_tel,employee_address,status)
value ('$user_number','$username','$password_crpt','$employee_name','employee_surname','$employee_email','$employee_tel','$employee_address','$status') ";
$result=mysql_query($sql);
if($result)
{
echo "</br></br></br></br></br></br></br></br></br></br></br></br>";
echo "<center><b><font color='blue'>เพิ่มผู้ใช้งานสำเร็จ !</font></b></center>";
}
else
{
echo "</br></br></br></br></br></br></br></br></br></br></br></br>";
echo "<center><b><font color='red'>เพิ่มผู้ใช้งานล้มเหลว !</font></b></center>";
}
?>
</br><center><a href='add_em01.php'><img src='picture/bottom_em_return.png' width='150'></a></center>";
</body>
</html>
Tag : PHP, MySQL, HTML/CSS
|
|
|
|
|
|
Date :
2012-09-06 12:21:55 |
By :
Sompoiiz |
View :
954 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผิดตรงนี้ครับ วงเล็บหายไป
$sql = " insert into employee ( user_number,username,password_crpt,employee_name,employee_surname,employee_email,employee_tel,employee_address,status)
value ('$user_number','$username','$password_crpt','$employee_name','employee_surname','$employee_email','$employee_tel','$employee_address','$status') ";
|
|
|
|
|
Date :
2012-09-06 13:32:02 |
By :
arm8957 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากครับ ...
จุดเดียวก็เสียวได้ TT
|
|
|
|
|
Date :
2012-09-06 15:53:30 |
By :
Sompoiiz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2012-09-06 16:12:25 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|