|
|
|
ขอโทษครับ ใช้โค้ดregister php ทางเวปแล้วมัน ไม่save ให้เลยรบกวนด้วยครับ |
|
|
|
|
|
|
|
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=utf-8" />
<title>Register</title>
</head>
<body>
<form action="save_register.php" name="register" method="post" >
<table width="400" border="0" cellspacing="2" cellpadding="0">
<tr>
<tr width="55%" align="center"><td align="center">สมัครสมาชิก</td></tr>
<tr>
<td width="55%">ชื่อผู้ใช้งาน</td>
<td width="45%"><input type="text" name="txtusername" id="txtusername" ?></td>
</tr>
<tr>
<td>รหัสผ่าน</td>
<td><input type="password" name="txtpassword" id="txtpassword" /></td>
</tr>
<tr>
<td>E-mail</td>
<td><input type="text" name="txtemail" id="txtemail" /></td>
</tr>
<tr>
<td>ชื่อ</td>
<td><input type="text" name="txtname" id="txtname" /></td>
</tr>
<tr>
<td>นามสกุล</td>
<td><input type="text" name="txtsurname" id="txtsurname" /></td>
</tr>
<tr>
<td>ที่อยู่</td>
<td><input type="text" name="txtaddress" id="txtaddress" /></td>
</tr>
<tr>
<td>รหัสไปรษณีย์</td>
<td><input type="text" name="txtcode" id="txtcode" /></td>
</tr>
<tr>
<td>เบอร์โทร</td>
<td><input type="text" name="tel" id="tel" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name"submit" id="submit" value="สมัครสมาชิก" /></td>
</tr>
</table>
</form>
</body>
</html>
save_register
Code (PHP)
<?
include("connect_db.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=utf-8" />
<title></title>
</head>
<body>
<?
if(trim($_POST["txtusername"]) == "")
{
echo "กรุณากรอกข้อมูล ชื่่อผูใช้งาน!";
exit();
}
if(trim($_POST["txtpassword"]) == "")
{
echo "กรุณากรอกข้อมูล รหัสผ่าน!";
exit();
}
if(trim($_POST["txtemail"]) == "")
{
echo "กรุณากรอกข้อมูล อีเมลล์!";
exit();
}
if(trim($_POST["txtname"]) == "")
{
echo "กรุณากรอกข้อมูล ชื่อของท่าน!";
exit();
}
if(trim($_POST["txtsurname"]) == "")
{
echo "กรุณากรอกข้อมูล นามสกุล!";
exit();
}
if(trim($_POST["txtaddress"]) == "")
{
echo "กรุณากรอกข้อมูล ที่อยู่!";
exit();
}
if(trim($_POST["txtcode"]) == "")
{
echo "กรุณากรอกข้อมูล รหัสไปรษณีย์!";
exit();
}
if(trim($_POST["tel"]) == "")
{
echo "กรุณากรอกข้อมูล เบอร์โทร";
exit();
}
$strSQL = "SELECT * FROM member WHERE username = '".trim($_POST['txtusername'])."' ";
$objQuery = mysql_query($strSQL)or die(mysql_error());
$objResult = mysql_fetch_array($objQuery)or die(mysql_error());
if($objResult)
{
echo "Username already exists!";
}
else
{
$strSQL = "INSERT INTO member (username,password,email,name,surname,address,code_id,tel_num) VALUES ( '".$_POST["txtusername"]."',
'".$_POST["txtpassword"]."','".$_POST["txtemail"]."','".$_POST["txtname"]."','".$_POST["txtsurname"]."','".$_POST["txtaddress"]."','".$_POST["txtcode"]."','".$_POST["tel"]."',)";
$objQuery = mysql_query($strSQL)or die(mysql_error());
echo "Register Completed!<br>";
echo "<br> Go to <a href='login.php'>Login page</a>";
}
mysql_close();
?>
</body>
</html>
ไม่บันทึกหรือRegister completed เลยครับ หน้าว่างเปล่า
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2015-02-26 16:40:03 |
By :
เด็กโข่ง |
View :
765 |
Reply :
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เชื่อมต่อฐานข้อมูลได้หรือไม่ครับ?
แล้วก็ใช้โครงสร้างภาษาแบบมาตรฐานนะครับ
Code (PHP)
<?PHP
.............โค้ด..............
?>
|
ประวัติการแก้ไข 2015-02-26 16:50:44
|
|
|
|
Date :
2015-02-26 16:45:27 |
By :
arm8957 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เชื่อมต่อฐานข้อมูลได้ครับ แต่พอมันมาหน้า save ไม่ไม่เตือนอะไรเลย แล้วก็ไม่เข้าฐานข้อมุลด้วยครับ
|
|
|
|
|
Date :
2015-02-26 16:55:10 |
By :
เด็กโข่ง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (SQL)
$strSQL = "INSERT INTO member (username,password,email,name,surname,address,code_id,tel_num) VALUES ( '".$_POST["txtusername"]."',
65.
'".$_POST["txtpassword"]."','".$_POST["txtemail"]."','".$_POST["txtname"]."','".$_POST["txtsurname"]."','".$_POST["txtaddress"]."','".$_POST["txtcode"]."','".$_POST["tel"]."',)";
ลูกน้ำเกินมาตัวนึง หลัง $_POST['tel']
|
ประวัติการแก้ไข 2015-02-26 17:00:11
|
|
|
|
Date :
2015-02-26 16:59:25 |
By :
progamer2000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับ ลองแล้วมันก็ไม่มีอะไรเลยครับ บันทึกก็ไม่ได้เหมือนเดิม ไม่ขึ้นError เลยครับ แต่ถ้าเข้าหน้า save เลย มันขึ้นแบบนี้
Notice: Undefined index: txtusername in C:\xampp\htdocs\gamecard\save_register.php on line 16
|
|
|
|
|
Date :
2015-02-26 17:08:32 |
By :
เด็กโข่ง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ต้องตรวจสอบตัวแปรก่อนครับ มันไม่ได้ Error แค่แจ้งให้ทราบว่า ควรตรวจสอบตัวแปร $POST[] ที่มี index = txtusername
ใช้ isset ตรวจสอบก่อนครับ
|
|
|
|
|
Date :
2015-02-26 17:23:19 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันไม่เข้า database เลยครับ ไม่เข้าใจ อยากรูมันผิดตรงไหน ดูหลายรอบแล้วครับ แล้วก็ไม่ Error ด้วยเลยงง
|
|
|
|
|
Date :
2015-02-26 17:44:08 |
By :
เด็กโข่ง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo $strSQL;
เอาค่าที่ได้มาโชว์หน่อย แล้วเอาไป run ใน phpmyadmin ดูครับ ว่ามันจะฟ้องว่าอะไร
|
|
|
|
|
Date :
2015-02-26 19:10:05 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันไม่ echo อะไรให้เลยครับ หน้าว่างเลย
|
|
|
|
|
Date :
2015-02-26 19:17:23 |
By :
เด็กโข่ง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยตอบหน่อยครับ ใครก็ได้ที่ทำเป็น ผมมือใหม่ ลองแก้ตามกระทู้อื่นแล้วทำไม่ได้ มันรันหน้าว่างมาให้ครับ
|
|
|
|
|
Date :
2015-02-26 21:04:17 |
By :
เด็กโข่ง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เช็คง่ายๆก่อนครับ ว่าหน้า save_register แสดงค่าอะไรไหมครับ echo แบบไม่เข้าเงื่อนไขอะไรเลย ลองส่งค่าดูครับ
|
|
|
|
|
Date :
2015-02-27 01:50:29 |
By :
weaned |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แหละครับ ไม่ได้ใส่ session_start ลงแค่นั้นเอง55555
ขอบคุณทุกคนที่เข้ามาตอบ ขอบคุณครับ
|
|
|
|
|
Date :
2015-02-28 11:07:03 |
By :
เด็กโข่ง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|