|
|
|
ช่วยดูโค้ด save ตัวนี้ให้ผมหน่อยครับ รีบมากคับ รบกวนด้วยนะครับ !! |
|
|
|
|
|
|
|
คือว่ามันจะ save ได้คนเดียวครับ ถ้าเราจะเพิ่มอีกคนมันติดตรงที่ idcard มันฟ้องว่าเคยใช้ไปแล้ว ทั้ง ๆ ที่ยังไม่ได้ใช้อะครับ
Code (PHP)
<?
session_start();
include ("connect.php");
?>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
<?
function show_msg($msg)
{
echo'<script language="Javascript">';
echo"alert('".$msg."')";
echo'</script>';
}
if($_REQUEST["button"]) {
if($_POST["code"] != $_SESSION["security_number"]) {
unset( $_SESSION['security_number']);
echo "<script type=\"text/javascript\">alert(\"»é͹¼ÅÅѾ¸ìäÁè¶Ù¡µéͧ\");history.back();</script>";
exit();
}
$_SESSION["Cus_Name"]= $_REQUEST['Cus_Name'];
$_SESSION["Cus_Idcard"]= $_REQUEST['Cus_Idcard'];
$_SESSION["Cus_BirthDay"] = $_REQUEST['Cus_BirthDay'];
$_SESSION["Cus_User"]= $_REQUEST['Cus_User'];
$_SESSION["Cus_Pass"]= $_REQUEST['Cus_Pass'];
$_SESSION["Cus_Phone"]= $_REQUEST['Cus_Phone'];
$_SESSION["Cus_Add"]= $_REQUEST['Cus_Add'];
$_SESSION["Cus_Country"]= $_REQUEST['Cus_Country'];
$_SESSION["Cus_Mail"]=$_REQUEST['Cus_Mail'];
$sql1 = "SELECT * FROM tbl_customer where Cus_Idcard ='".$_REQUEST['Cus_Idcard']."'";
$query = mysql_query($sql1);
$num = mysql_num_rows($query);
if($num >= 1){
echo '<script type="text/javascript">alert("This ID Card is already Taken, please register");history.back(-1);</script>';
exit();
}
$sql2 = "SELECT * FROM tbl_customer where Cus_User ='".$_REQUEST['Cus_User']."'";
$query = mysql_query($sql2);
$num = mysql_num_rows($query);
if($num >= 1){
echo '<script type="text/javascript">alert("This User is already Taken, please register");history.back(-1);</script>';
exit();
}
$sql3="SELECT count(Cus_Mail) as xemail FROM `tbl_customer` WHERE Cus_Mail ='".$_SESSION["Cus_Mail"]."' ";
$rows=mysql_query($sql3) or die(mysql_error());
$result1=mysql_fetch_assoc($rows);
if($result1["xemail"]>=1){
echo '<script type="text/javascript">alert("This Email is already taken, please register.");history.back(-1);</script>';
exit();
}
$sql="INSERT INTO tbl_customer(Cus_Name,Cus_idcard,Cus_BirthDay, Cus_User,Cus_Pass,Cus_Phone,Cus_Add,Cus_Country,Cus_Mail) VALUES('".$_SESSION["Cus_Name"]."' ,'".$_SESSION["Cus_Idcard"]."' ,'".$_SESSION["Cus_BirthDay"]."','".$_SESSION["Cus_User"]."', '".$_SESSION["Cus_Pass"]."','".$_SESSION["Cus_Phone"]."','".$_SESSION["Cus_Add"]."', '".$_SESSION["Cus_Country"]."','".$_SESSION["Cus_Mail"]."')";
$result = mysql_query($sql) or die(mysql_error());
show_msg("Register Complete");
echo "<meta http-equiv='refresh' content='0;URL=http://localhost/project/register_customer.php'>";
}else{
show_msg("Error Try Again !!");
echo "<meta http-equiv='' content='0;URL=http://localhost/project/register_customer.php'>";
}
?>
Tag : PHP
|
ประวัติการแก้ไข 2013-01-13 19:07:42
|
|
|
|
|
Date :
2013-01-13 17:25:58 |
By :
l3alLkisS |
View :
794 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$sql1 = "SELECT * FROM tbl_customer where Cus_Idcard ='".$_REQUEST['Cus_Idcard']."'";
$query = mysql_query($sql1);
$num = mysql_num_rows($query);
if($num >= 1){
echo '<script type="text/javascript">alert("This ID Card is already Taken, please register");history.back(-1);</script>';
exit();
}
แสดงว่ามันมี record น่ะครับ หรือไม่ลอง echo $sql1; แล้วเอาไปรันใน SQL ดูครับ
|
|
|
|
|
Date :
2013-01-13 20:08:32 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ในฐานข้อมูล Cus_idcard เป็น primary key หรือเปล่าเครับ
|
|
|
|
|
Date :
2013-01-14 17:51:44 |
By :
Ex-[S]i[L]e[N]t |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|