|
 |
|
มีปัญหาการเช็คอีเมลล์ โดยใช้ Function FILTER_VALIDATE_EMAIL ครับ ช่วยดูโค้ดให้ทีนะครับ |
|
 |
|
|
 |
 |
|
คือถ้าเอาลูป เช็คพาสเวิร์ กับ เช็คอีเมลล์สลับกัน มันจะทำงานแค่ลูปแรกอย่างเดียวนะครับ
ลูปที่เช็คอีเมลล์ ผมลองเปลี่ยนเป็นให้แสดงอีเมลล์ที่รับเข้ามาอย่างเดียวก็ไม่แสดงครับ คือค่ามันรับเข้ามาแล้ว แต่ไม่รู้ทำไมว่าลูปนี้ไม่ทำงานครับ พอรันแล้วก็มีแต่สีขาวครับ
config.inc.php
function check_email($email){
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
echo "อีเมลล์ไม่ถูกต้อง<br>";
//echo"<a href=javascript:histroy.back();>กลับไปแก้ไข</a>";
}else{
echo "ผ่านๆๆ Get Outt!";
}
}
addregister.php
<?$emil = $_POST['email'];
else if($password != $comfirm_password){ //ตรวจสอบรูปแบบการป้อนอีเมลล์
echo "<SCRIPT>alert('password ทั้ง 2 ช่องไม่ตรงกัน');history.back(-1);</script>";
exit();
if(check_email($email)){ //ตรวจสอบอีเมลล์ตรงกันหรือไม่
echo "<SCRIPT>alert('อีเมลล์ไม่ถูกต้อง');history.back(-1);</script>";
}
else{ //เพิ่มข้อมูลลงฐานข้อมูล
$date_register=date('l, j-m-Y, H:i:s A'); // วันเดือนปี เวลาที่สมัคร
$strSQL = "INSERT INTO mamber (UserID, Username, Password, Email, Name, Sex, Region, Day, Month, Year, Comment, Dateregister) VALUES ('NULL', '$m[username]', '$m[password]', '$m[email]', '$m[name]', '$m[sex]', '$m[region]', '$m[day]', '$m[month]', '$m[year]', '$m[comment]', '$date_register') ";
$objQuery = mysql_query($strSQL) or die ("ไม่สามารถติดต่อฐานข้อมูลเพื่อบันทึกข้อมูลเหล่านี้ได้");
if($objQuery){
echo "บันทึกข้อมูลของท่านเรียบร้อยแล้ว";
echo "<br> Go to <a href='register.php'>Register Again</a>"."<br> Go to <a href='showregister.php'>แสดงข้อมูล</a>";
} else {
echo "!!!Error Save [".$strSQL."]";
exit();
}
mysql_close($objConnect);
}
?>
ช่วยดูให้ทีครับ เหมือนว่ามันไม่เข้าไปทำงาน หรือข้ามการทำงานของลูปนี้เลยครับ
addregister
if(check_email($email)){ //ตอนสอบอีเมลล์ตรงกันหรือไม่
echo "<SCRIPT>alert('อีเมลล์ไม่ถูกต้อง');history.back(-1);</script>";
}
รบกวนด้วยนะครับ ขอบคุณมากๆ ครับ 
Tag : PHP, HTML/CSS

|
ประวัติการแก้ไข 2011-06-27 07:33:03 2011-06-27 07:34:50
|
 |
 |
 |
 |
Date :
2011-06-27 07:31:30 |
By :
fogza |
View :
1552 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่วินครับ มันเหมือนเดิมครับ แสดงหน้าขาวๆเหมือนเดิม โดยผมเขียนแบบนี้ครับ
Code (PHP)
<?pho
include("config.inc.php");
$strSQL = "SELECT Username FROM mamber WHERE Username='$username' ";
$objQuery = mysql_query($strSQL) or die("ติดต่อฐานข้อมูลเพื่อตรวจสอบผู้ใช้งานไม่ได้");
$numrow = mysql_num_rows($objQuery);
if($numrow != 0){
echo "<SCRIPT>alert('[$username] รายชื่อนี้ถูกใช้งานแล้ว');history.back(-1);</script>";
exit();
}
else if($password != $comfirm_password){ //ตรวจสอบรูปแบบการป้อนพาสเวิร์ด
echo "<SCRIPT>alert('password ทั้ง 2 ช่องไม่ตรงกัน');history.back(-1);</script>";
exit();
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])){ //ตรวจสอบรูปแบบการป้อนอีเมลล์
echo "<center>Invalid email</center>";
}
else{ //เพิ่มข้อมูลลงฐานข้อมูล
$date_register=date('l, j-m-Y, H:i:s A'); // วันเดือนปี เวลาที่สมัคร
$strSQL = "INSERT INTO mamber (UserID, Username, Password, Email, Name, Sex, Region, Day, Month, Year, Comment, Dateregister) VALUES ('NULL', '$m[username]', '$m[password]', '$m[email]', '$m[name]', '$m[sex]', '$m[region]', '$m[day]', '$m[month]', '$m[year]', '$m[comment]', '$date_register') ";
$objQuery = mysql_query($strSQL) or die ("ไม่สามารถติดต่อฐานข้อมูลเพื่อบันทึกข้อมูลเหล่านี้ได้");
if($objQuery){
echo "บันทึกข้อมูลของท่านเรียบร้อยแล้ว";
echo "<br> Go to <a href='register.php'>Register Again</a>"."<br> Go to <a href='showregister.php'>แสดงข้อมูล</a>";
} else {
echo "!!!Error Save [".$strSQL."]";
exit();
}
mysql_close($objConnect);
}
}
?>
ต้องทำยังไงดีครับ แก้ทั้งวันแล้วยังไม่ได้เลย เช็คอีเมลล์เนี่ย - -"
ขอบคำแนะนำด้วยครับ ขอบคุณมากครับ
|
ประวัติการแก้ไข 2011-06-27 16:30:01
 |
 |
 |
 |
Date :
2011-06-27 16:27:20 |
By :
fogza |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอดันนิดนึงนะครับ ยังแก้ไม่ได้เลยครับพี่วัน 
ลองเปลี่ยนไปหลายๆ แบบแล้วครับ ยังไม่ได้ซะทีเลยครับ
|
 |
 |
 |
 |
Date :
2011-06-28 08:49:29 |
By :
fogza |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|