|
 |
ทำไมป้อนข้อมูลด้วย text field แล้วเข้าใน database แค่บางตัวค่ะ ไม่ทราบว่าผิดตรงไหน มือใหม่ค่ะ |
|
 |
|
|
 |
 |
|
คือต้องการป้อนข้อมูลแบบธรรมดาเลยค่ะ มีการป้อนรู้ภาพด้วย แต่ตรงรูปภาพไม่มีปัญหาค่ะ เข้าฐานข้อมูลและโฟลเดอร์ที่ตั้งไว้เรียบร้อยดี

แต่พอป้อนเสร็จข้อมูลเข้าแค่ regId , regName , RegImg ค่ะ

รบกวนด้วยนะคะ ขอบคุณค่ะ
main_regis.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>Untitled Document</title>
</head>
<body>
<form action="done_regis.php" method="post" enctype="multipart/form-data" name="form2" id="form2">
<div align="center">
<p>รหัสลงทะเบียน :
<input name="regId" type="text" disabled="disabled" maxlength="10" />
<br />
ชื่อ :
<input type="text" name="txtregName" maxlength="20" />
<br />
นามสกุล :
<input name="txtregLast" type="text" maxlength="20" />
<br />
รหัสบัตรประชาชน :
<input type="text" name="txtregIdno" maxlength="13" />
<br />
ที่อยู :
<input type="text" name="txtregAddress" maxlength="100" />
<br />
เบอร์โทร :
<input type="text" name="txtreTel" maxlength="12" />
<br />
จำนวน :
<input type="text" name="txtregQuan" maxlength="1" />
<br />
ราคา :
<input type="text" name="txtrePrice" maxlength="7" />
<br />
หลักฐานการโอนเงิน
<input type="file" name="filRegImg" maxlength="100" />
<br />
<input name="btnSubmit" type="submit" value="Submit" />
</p>
</p>
</div>
</form>
<p> </p>
</body>
</html>
done_regis.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>Untitled Document</title>
</head>
<body>
<?php
$fileName = "_".$_FILES["filRegImg"]["name"];
if(move_uploaded_file($_FILES["filRegImg"]["tmp_name"],"proofimg/".$fileName))
{
echo "Copy/Upload Complete<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","root","password") or die("Error Connect to Database");
$objDB = mysql_select_db("mothana");
$strSQL = "INSERT INTO register ";
$strSQL .="(regName,RegImg) VALUES ('".$_POST["txtregName"]."','".$fileName."'),";
$objQuery = mysql_query($strSQL);
mysql_close($objConnect);
}
?>
</body>
</html>
Tag : MySQL, HTML, Apache, Appserv
|
|
 |
 |
 |
 |
Date :
2019-12-01 15:00:17 |
By :
1301025870102882 |
View :
691 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ปัญหาคืออะไรครับ ดูจากโค๊ด generate sql statement ก็เก็บค่าถูกต้องแล้วนี่ครับ
กำหนดไว้ 2 field ส่วน id เป็น autoincrement สร้างเองโดยอัตโนมัติ
$strSQL .="(regName,RegImg) VALUES ('".$_POST["txtregName"]."','".$fileName."'),";
ถ้าอยากเพิ่มฟีลด์อื่นๆ ก็ใส่เพิ่มเข้าไป
$strSQL .="(regName, fldname1, fldname2, RegImg)
VALUES ('".$_POST["txtregName"]."','".$_POST["fldname1"]."','".$_POST["fldname2"]."','".$fileName."'),";
แต่แนะนำอย่าใช้ global variable โดยตรงกับการ generate sql statement
ให้ใช้การแปลงค่าก่อน หรือให้ใช้เครื่องมือของ mysql เอง ด้วยคำสั่ง mysqli_prepare ค้นหาอ่านแล้วทดลองเอาเองครับ
มันมีคำสั่งที่เกี่ยวข้องหลายคำสั่ง ป้องการ sql injection ได้อย่างดี
อ้ออีกอย่างเขาเลิกใช้ M Y S Q L กันแล้วครับ
เขาใช้ M Y S Q L I กันแล้วครับ
|
 |
 |
 |
 |
Date :
2019-12-02 08:57:14 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|