|
|
|
รบกวนช่วยดู Code PHP เช็คชื่อผู้ใช้งานซ้ำให้หน่อยครับ |
|
|
|
|
|
|
|
Code (PHP)
<?
/*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");
$sqlstr="select username from employee where username =' ".trim($_post["username"])." ' ";
$objQuery=mysql_query($sqlstr);
$row=mysql_num_rows($objQuery);
if($row > 0)
{
echo "ชื่อผู้ใช้งานนี้มีอยู่แล้ว !";
}
echo $username;
$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>";
echo "</br>"."<center><a href='show_em.php'><img src='picture/bottom_show_em_return.png' width='150'></a></center>";
}
else
{
echo "</br></br></br></br></br></br></br></br></br></br></br></br>";
echo "<center><b><font color='red'>เพิ่มผู้ใช้งานล้มเหลว !</font></b></center>";
echo "</br>"."<center><a href='add_em01.php'><img src='picture/bottom_em_return.png' width='150'></a></center>";
}
?>
</body>
</html>
ขอบคุณล่วงหน้าครับผม
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2012-09-07 21:29:46 |
By :
Sompoiiz |
View :
2390 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่อธิบาย หน่อยหรือไร
|
|
|
|
|
Date :
2012-09-07 22:47:32 |
By :
Krungsri |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากครับ mr.win
|
|
|
|
|
Date :
2012-10-08 13:18:15 |
By :
face |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|