|
 |
|
[PHP] ช่วยด้วยครับ..เรื่องการตรวจชื่อ user ซ้ำครับ แก้ไม่ได้ซะที |
|
 |
|
|
 |
 |
|
ตอนนี้สมัครใช้ accountid ซ้ำก็ยังตรวจว่าผ่าน (แต่ไม่ได้ทำการบันทึกลง DB ใหม่)
แต่ถ้าหากสมัครใช้ accountid ไม่ซ้ำก็จะทำการบันทึกลง DB ใหม่ปกติครับ
รบกวนช่วยดูให้ด้วยครับ..ขอบคุณครับ
Code (PHP)
<?
mysql_connect("localhost","root","1234");
mysql_select_db("register");
mysql_query("SET NAMES UTF8");
if(trim($_POST["accountid"]) == "")
{
header("location:register_false.php");
exit();
}
if(trim($_POST["password"]) == "")
{
header("location:register_false.php");
exit();
}
if(trim($_POST["name"]) == "")
{
header("location:register_false.php");
exit();
}
if(trim($_POST["age"]) == "")
{
header("location:register_false.php");
exit();
}
if(trim($_POST["gender"]) == "")
{
header("location:register_false.php");
exit();
}
if(trim($_POST["email"]) == "")
{
header("location:register_false.php");
exit();
}
if(trim($_POST["address"]) == "")
{
header("location:register_false.php");
exit();
}
$strSQL = "SELECT * FROM register_info WHERE accountid_info = '".trim($_POST["accountid"])."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
header("location:register_reapeat.php");
}
else
{
$strSQL = "INSERT INTO register_info (accountid_info,password_info,name_info,age_info,gender_info,email_info,address_info) VALUES ('".$_POST["accountid"]."',
'".$_POST["password"]."','".$_POST["name"]."','".$_POST["age"]."','".$_POST["gender"]."','".$_POST["email"]."','".$_POST["address"]."')";
$objQuery = mysql_query($strSQL);
}
header("location:register_true.php");
mysql_close();
?>
Tag : PHP, MySQL

|
ประวัติการแก้ไข 2012-08-25 01:20:44
|
 |
 |
 |
 |
Date :
2012-08-25 01:18:28 |
By :
talememorize |
View :
1015 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณลืม
Code (PHP)
if(mysql_num_rows($objQuery) > 0){
//duplicate account
}else{
//account register
}
รึป่าวฦ
|
 |
 |
 |
 |
Date :
2012-08-25 01:27:33 |
By :
wuttdan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบความคิดเห็นที่ : 2 เขียนโดย : talememorize เมื่อวันที่ 2012-08-25 02:31:24
รายละเอียดของการตอบ ::
Code (PHP)
$strSQL = "SELECT * FROM register_info WHERE accountid_info = '".trim($_POST["accountid"])."' ";
$objQuery = mysql_query($strSQL);
if(mysql_num_rows($objQuery) > 0){
header("location:register_reapeat.php");
//echo "Duplicate account, Please try again";
}else{
$strSQL = "INSERT INTO register_info (accountid_info,password_info,name_info,age_info,gender_info,email_info,address_info) VALUES ('".$_POST["accountid"]."',
'".$_POST["password"]."','".$_POST["name"]."','".$_POST["age"]."','".$_POST["gender"]."','".$_POST["email"]."','".$_POST["address"]."')";
$objQuery = mysql_query($strSQL);
if(!$objQuery){
echo "Account progress error.";
exit();
}
header("location:register_true.php");
}
mysql_close();
|
ประวัติการแก้ไข 2012-08-25 02:44:33 2012-08-25 02:46:48
 |
 |
 |
 |
Date :
2012-08-25 02:43:34 |
By :
wuttdan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|