|
 |
|
รบกวนดูโค้ตนี่หน่อยเข้า insert ลงฐานข้อมูลได้บางฟิวด์ |
|
 |
|
|
 |
 |
|
insert ลงฐานข้อมูลได้เป็นบางฟิวด์

Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?
session_start();
mysql_connect("localhost","root","1234");
mysql_select_db("register");
//แทรกแก้ภาษาไทยลงฐานข้อมูล
$dbLink = mysql_connect("localhost", "root","1234");
mysql_query("SET character_set_client=utf8", $dbLink);
mysql_query("SET character_set_connection=utf8", $dbLink);
//
$strSQL = "SELECT * FROM member WHERE Username = '".trim($_POST['usernamesignup'])."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "ชื่อนี้มีผู้ใช้แล้ว กรุณาเปลี่ยนใหม่";
}
else
{
$strSQL = "INSERT INTO member (Name,Username,Password,Email,Status,SID,Active) VALUES ('".$_POST["namesignup"]."' ,'".$_POST["usernamesignup"]."', '".md5($_POST["passwordsignup"])."','".$_POST["emailsignup"]."','USER','".session_id()."','No')";
$objQuery = mysql_query($strSQL);
$Uid = mysql_insert_id();
echo "การลงทะเบียนเรียบร้อยแล้ว!<br>กรุณาเข้าไปตรวจสอบในเมล์ของท่าน (อาจอยู่ในโฟลเดอร์ถังขยะ) เพื่อยืนยันการเป็นสมาชิก";
$strTo = $_POST["emailsignup"];
$strSubject = "ยืนยันการเป็นสมาชิก";
$strHeader = "Content-type: text/html; charset=or UTF-8\n"; // or UTF-8 windows-874//
$strHeader .= "From: [email protected]\nReply-To: [email protected]";
$strMessage = "";
$strMessage .= "ยินดีต้อนรับคุณ : ".$_POST["namesignup"]."<br>";
$strMessage .= "=================================<br>";
$strMessage .= "คลิกบนลิ้งค์เพื่อการยืนยันการสมัครสมาชิก <br>";
$strMessage .= "http://www.xxx.com/regis/activate.php?sid=".session_id()."&uid=".$Uid."<br>";
$strMessage .= "=================================<br>";
$strMessage .= "welcome<br>";
$flgSend = mail($strTo,$strSubject,$strMessage,$strHeader);
}
mysql_close();
?>
Tag : PHP, MySQL, HTML/CSS, Windows

|
|
 |
 |
 |
 |
Date :
2013-12-14 11:59:07 |
By :
ธีระ |
View :
606 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
กำหนดขนาด ไว้พอดีกับข้อมูลหรอเปล่า
|
 |
 |
 |
 |
Date :
2013-12-14 12:03:46 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ปัญหานี้อาจจะเกิดจาก $_POST["namesignup"], $_POST["emailsignup"] และ $_POST["usernamesignup"] มันไม่มีค่า
ลองเช็คดูว่ามันมีค่าส่งมาจากฟอร์มจริงหรือไม่
และเช็คดูด้วยว่า <input> ใน <form> มีค่าแอตทริบิวท์ name ตรงกันกับที่เรียกใช้ใน PHP หรือไม่ (ตัวพิมพ์เล็กใหญ่ก็ต้องตรงกัน)
การเช็คง่ายๆ ว่ามันมีค่าส่งมาหรือไม่ ให้ใช้ print_r() หรือ var_dump()
หรือเปิด error_reporting เพื่อแสดง error ในกรณีที่เรียกใช้ตัวแปรที่ยังไม่ได้กำหนดค่าด้วย error_reporting(-1);
Code (PHP)
<?
session_start();
print_r($_POST); // แสดงค่าที่ส่งมาจากฟอร์ม
exit; // จบโปรแกรมไปเลย เพื่อลองเช็คค่าที่ส่งมาจากฟอร์มเฉยๆ
mysql_connect("localhost","root","1234");
mysql_select_db("register");
//แทรกแก้ภาษาไทยลงฐานข้อมูล
$dbLink = mysql_connect("localhost", "root","1234");
mysql_query("SET character_set_client=utf8", $dbLink);
mysql_query("SET character_set_connection=utf8", $dbLink);
...
|
 |
 |
 |
 |
Date :
2013-12-14 13:21:02 |
By :
K |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|