|
 |
|
กรอกข้อมูลจาก form เรียบร้อย พอกด Submit ก็ขึ้นว่า error=select * from member where username='a' |
|
 |
|
|
 |
 |
|
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
</head>
<body>
<?
include ("Connect.php");
$username =$_POST['username'];
$password =$_POST['password'];
$confirm =$_POST['confirm'];
$name =$_POST['name'];
$lastname =$_POST['lastname'];
$gender =$_POST['gender'];
$birthday =$_POST['birthday'];
$address =$_POST['address'];
$email =$_POST['email'];
//ตรวจสอบข้อมูลที่ไม่ควรให้มีการเว้นว่าง
if(empty ($username) || empty ($password) || empty ($confirm) || empty ($name) || empty ($lastname))
{
echo "<script>alert ('กรอกข้อมูลไม่ครบ');history.back();</script>";
exit();
}
//ตรวจสอบ Password และ confirm Password ต้องกรอกตรงกัน
if ($password != $confirm)
{
echo "<script>alert('Please check password');history.back();</script>";
exit();
}
//ตรวจสอบวันเกิดที่กรอกเข้ามานั้น เป็นวันที่ ที่มีอยู่จริงหรือไม่
if (!checkdate($month,$day,$year))
{
echo "<script>alert('Please check birthday');history.back();</script>";
exit();
}
//select ข้อมูล username ว่าเคยมีการใช้งานไปแล้วหรือไม่
$sqlC = "select * from member where username='$username' ";
$queryC = mysql_query($sqlC) or die("error=$sqlC");
$numC = mysql_num_rows($queryC);
//ถ้า username มีการใช้งานไปแล้ว จะให้แจ้งเตือนเพื่อให้เปลี่ยน username ที่ต้องการ
if($numC != 0)
{
echo"<script>alert('Please change USERNAME');history.back();</script>";
exit();
}else
{
//ถ้า username ยังไม่ต้องการใช้งานเตรียมนำข้อมูลไปบันทึกลงในตาราง
$birthday = "$year-$month-$day"; //เตรียมข้อมูลจากlist/menu ทั้ง3มาจัดเพื่อเตรียมเก็บลงตาราง
$password = base64_encode ($password); //เข้ารหัสข้อมูล ก่อนจัดเก็บข้อมูลลงตาราง
$sql = "insert into member values('','$username','$password','$name','$lastname','$gender','$birthday','$address','$email')";
mysql_query($sql) or die ("error=$sql");
echo "<script>alert ('Complete'); window.location='index.php';</script>";
}
?>
</body>
</html>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-07-09 20:23:59 |
By :
dream06 |
View :
1103 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอา select * from member where username='a' ไป query ใน mysql เลยครับ ได้ว่ายังไง
|
 |
 |
 |
 |
Date :
2012-07-09 20:45:38 |
By :
joesimikung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้ครับ
|
ประวัติการแก้ไข 2012-07-09 20:56:01
 |
 |
 |
 |
Date :
2012-07-09 20:53:51 |
By :
dream06 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|