|
 |
|
อยากได้โค๊ดการอัพรูปในฟอร์มเดียวกันกับข้อมูลส่วนตัว แล้วโชวภาพตัวอย่างในหน้านั้นเลยครับ |
|
 |
|
|
 |
 |
|
PHP สร้างฟอร์มสำหรับ Upload รูปภาพลงในฐานข้อมูล MySQL พร้อมกับ
PHP MySQL กับ Login Form ทำระบบ User ล็อกอิน แบบง่าย ๆ ด้วย PHP และ MySQL โดยทำการตรวจสอบ Username และ Password
อ่านจาก 2 บทความนี้ครับ
|
 |
 |
 |
 |
Date :
2014-01-21 20:00:50 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอนนี้เลือกรูปและโชวรูปในหน้าฟอร์มได้แล้วครับ แต่ยังไม่เข้าใจว่าจะใส่โคดอัพรูปตรงไหน
ข้างล่างนี้เป็นโค๊ด insert ข้อมูลปกติครับ แต่อยากทราบว่าต้องใส่โค๊ด อัพรูปตรงไหน และต้องสร้างฐานข้อมูลใหม่ไหม แต่จริงๆแล้วอยากเก็บในตารางนี้เลย เพราะเวลาเรียกดูข้อมูลส่วนตัวจะต้องดึงรูปแต่ละคนมาด้วยครับ
Code (PHP)
<?
include"../../connect.php";
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?
if($_POST[Insert]){
$date_user=$selbyear.'-'.$selbmonth.'-'.$selbdate;
$sql="INSERT INTO `db_mfes`.`users`SET
`U_NUMBER` = '$txt_number',
`U_PREFIX` = '$txt_title',
`U_NAME` = '$txt_name',
`U_LAST` = '$txt_lastname',
`U_NAME_TH` = '$txt_name_th',
`U_LAST_TH` = '$txt_last_th',
`U_NICK` = '$txt_nickname',
`U_IDCARD` = '$txt_idcard',
`U_MOBILES1` = '$txt_mobile1',
`U_MOBILES2` = '$txt_mobile2' ,
`U_TELS` = '$txt_tel' ,
`U_BIRTHDAY` = '$date_user' ,
`U_AGE` = '$txt_age' ,
`U_SCHOOL` = '$txt_school' ,
`U_POSITION` = '$txt_position' ,
`U_PERMENT_ADD` = '$txt_paement_address' ,
`U_MARITAL` = '$status' ,
`U_FACES` = '$txt_facebook' ,
`U_TWS` = '$txt_twister' ,
`U_EMAILS` = '$txt_email' ,
`U_LINES` = '$txt_line' ,
`U_USERNAME` = '$txt_user' ,
`U_PASS` = '$txt_pass' ,
`U_CLAIM` = '$txt_select' ,
`U_NAME_NEX` = '$txt_name_nex' ,
`U_RELATIONSHIP` = '$txt_relation' ,
`U_MOBILE1` = '$txt_mo1' ,
`U_MOBILE2` = '$txt_mo2' ,
`U_TELEPHONE_NEX` = '$txt_phone_nex'
;
";
if( mysql_query($sql)){//or die(mysql_error());
echo "<br><center><h2> เพิ่มข้อมูลผู้ใช้เรียบร้อยแล้ว</h2></center>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=../insert_student_private.php\">";
exit;
}else {
echo "<br><center><h2>ไม่สามารถเพิ่มข้อมูลผู้ใช้ได้</h2></center>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=../insert_student_private.php\">";
exit;
}
}else{
echo "<br><center><h2>ยกเลิกการเพิ่มข้อมูลผู้ใช้</h2></center>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=../insert_student_private.php\">";
}
?>
|
 |
 |
 |
 |
Date :
2014-01-23 12:50:55 |
By :
wita |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแล้วมันขึ้น error แบบนี้อะครับ แต่ข้อมูลอย่างอื่นที่กรอกไปมันบันทึกลงฐานข้อมูลได้แล้วครับ

อันนี้โคดครับ
Code (PHP)
<?
include"../../connect.php";
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?
if($_POST[Insert]){
$date_user=$selbyear.'-'.$selbmonth.'-'.$selbdate;
if(move_uploaded_file($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]))
{
echo "Copy/Upload Complete<br>";
}
$sql="INSERT INTO `db_mfes`.`users`SET
`U_NUMBER` = '$txt_number',
`U_PREFIX` = '$txt_title',
`U_NAME` = '$txt_name',
`U_LAST` = '$txt_lastname',
`U_NAME_TH` = '$txt_name_th',
`U_LAST_TH` = '$txt_last_th',
`U_NICK` = '$txt_nickname',
`U_IDCARD` = '$txt_idcard',
`U_MOBILES1` = '$txt_mobile1',
`U_MOBILES2` = '$txt_mobile2' ,
`U_TELS` = '$txt_tel' ,
`U_BIRTHDAY` = '$date_user' ,
`U_AGE` = '$txt_age' ,
`U_SCHOOL` = '$txt_school' ,
`U_POSITION` = '$txt_position' ,
`U_PERMENT_ADD` = '$txt_paement_address' ,
`U_MARITAL` = '$status' ,
`U_FACES` = '$txt_facebook' ,
`U_TWS` = '$txt_twister' ,
`U_EMAILS` = '$txt_email' ,
`U_LINES` = '$txt_line' ,
`U_USERNAME` = '$txt_user' ,
`U_PASS` = '$txt_pass' ,
`U_CLAIM` = '$txt_select' ,
`U_NAME_NEX` = '$txt_name_nex' ,
`U_RELATIONSHIP` = '$txt_relation' ,
`U_MOBILE1` = '$txt_mo1' ,
`U_MOBILE2` = '$txt_mo2' ,
`U_TELEPHONE_NEX` = '$txt_phone_nex' ,
`U_IMG` = '".$_FILES["filUpload"]."'
;
";
if( mysql_query($sql)){//or die(mysql_error());
echo "<br><center><h2> เพิ่มข้อมูลผู้ใช้เรียบร้อยแล้ว</h2></center>";
// echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=../insert_student_private.php\">";
exit;
}else {
echo "<br><center><h2>ไม่สามารถเพิ่มข้อมูลผู้ใช้ได้</h2></center>";
// echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=../insert_student_private.php\">";
exit;
}
}else{
echo "<br><center><h2>ยกเลิกการเพิ่มข้อมูลผู้ใช้</h2></center>";
//echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=../insert_student_private.php\">";
}
?>
|
 |
 |
 |
 |
Date :
2014-01-23 15:49:26 |
By :
wita |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|