|
 |
|
ช่วยดูโค้ด เพิ่มรูปภาพและข้อมูลเข้า Mysql หน่อยครับ |
|
 |
|
|
 |
 |
|
อับโหลดรูปได้ มีรูปที่โฟเดอร์ แต่ข้อมูลทั้งหมดไม่มีใน Mysql เลย ช่วยดูทีครับ
Code (PHP)
<?
mysql_connect("localhost","root","123456");
mysql_select_db("my");
if(copy($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]))
{
echo "ไม่ได้เลือกภาพ";
exit();
}
if(trim($_POST["txtmem_username"]) == "")
{
echo "กรุณากรอก Username!";
exit();
}
if(trim($_POST["txtmem_password"]) == "")
{
echo "กรุณากรอก Password!";
exit();
}
if($_POST["txtmem_password"] != $_POST["txtmem_conpassword"])
{
echo "Password ไม่ตรงกัน!";
exit();
}
if(trim($_POST["txtmem_name"]) == "")
{
echo "กรุณากรอก ชื่อ!";
exit();
}
$strSQL = "SELECT * FROM member WHERE mem_username = '".trim($_POST['txtmem_username'])."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "Username มีแล้ว!";
}
else
{
$strSQL = "INSERT INTO member (mem_id, mem_name, mem_sex, mem_age, mem_address, mem_tel, mem_username, mem_password, mem_status,mem_pic) VALUES
(
'".$_POST["txtmem_id"]."',
'".$_POST["txtmem_name"]."',
'".$_POST["txtmem_sex"]."',
'".$_POST["txtmem_age"]."',
'".$_POST["txtmem_address"]."',
'".$_POST["txtmem_tel"]."',
'".$_POST["txtmem_username"]."',
'".$_POST["txtmem_password"]."',
'".$_POST["txtmem_status"]."'
'".$_POST["filUpload"]["name"]."'
)";
$objQuery = mysql_query($strSQL);
echo "ลงทะเบียนเรียบร้อย!<br>";
echo "<br> Go to <a href='home.php'>เข้าสู่ระบบที่นี่</a>";
}
mysql_close();
?>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2011-01-27 12:42:45 |
By :
hnu25 |
View :
1287 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้ว ครับ...
|
 |
 |
 |
 |
Date :
2011-01-27 14:21:45 |
By :
hnu25 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|