|
 |
|
รบกวนดูโค้ดให้หน่อยค่ะ แอดข้อมูลไม่ลงฐานข้อมูล ในข้อมูลที่แอดมีไฟล์รูปด้วย |
|
 |
|
|
 |
 |
|
รบกวนดูโค้ดให้หน่อยค่ะ แอดข้อมูลไม่ลงฐานข้อมูล ในข้อมูลที่แอดมีไฟล์รูปด้วย
Code (PHP)
<form action="index2.php?id=28" method="post" enctype="multipart/form-data">
<table width="775" border="0" align="center">
<tr>
<td align="left" valign="top">
<div id="mainadd">
<div id="add"><img src="../images/add.png" width="24" height="24" align="absmiddle" /> เพิ่มสาขา</div>
<br />
<table width="620" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="77%" align="left" valign="top"><table width="106%" cellpadding="2" cellspacing="2">
<tr>
<td width="24%">ชื่อสาขา ::</td>
<td width="76%"><input type="text" name="title" id="title" /></td>
</tr>
<tr>
<td>รายละเอียด ::</td>
<td> </td>
</tr>
<tr>
<td colspan="2"><textarea name="content" cols="70" id="content" ></textarea></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"> แผนที่ ::
<input name="map" type="file" id="map" size="60" /></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2">
<input name="status" id="status" type="checkbox" value="1" >
แสดง/ซ่อน</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><div id="buttom"><input type="submit" name="button5" id="button5" value="บันทึก" />
<input type="reset" name="button6" id="button6" value="ยกเลิก" />
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top"> </td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</form>
<script type="text/javascript">
// This is a check for the CKEditor class. If not defined, the paths must be checked.
if ( typeof CKEDITOR == 'undefined' )
{
document.write(
'<strong><span style="color: #ff0000">Error</span>: CKEditor not found</strong>.' +
'This sample assumes that CKEditor (not included with CKFinder) is installed in' +
'the "/ckeditor/" path. If you have it installed in a different place, just edit' +
'this file, changing the wrong paths in the <head> (line 5) and the "BasePath"' +
'value (line 32).' ) ;
}
else
{
var content = CKEDITOR.replace( 'content' );
CKFinder.setupCKEditor( content, '../js/ckfinder/' ) ;
}
</script>
Code (PHP)
<?
$title=$_POST['title'];
$content=$_POST['content'];
$status=$_POST['status'];
$map=$_FILES['map']['tmp_name'];
$map_name=$_FILES['map']['name'];
$map_size=$_FILES['map']['size'];
$map_type=$_FILES['map']['type'];
$date_today=date("Y-m-d");
if($name_ev="" or $detail=""){
echo "<h2> กรอกข้อมูลไม่ครบ </h2>";
exit();
}
include "../admin/config.php";
$result = mysql_query("INSERT INTO tb_contact VALUES (null,'$title','$content','','$status','$date_today')");
$ext = strtolower(end(explode('.',$map_name)));
if($ext == "jpg" or $ext == "jpeg" or $ext == "png" or $ext == "gif"){
$sql="select max(id_con) from tb_contact";
$result=mysql_db_query($dbname,$sql);
$r=mysql_fetch_array($result);
$id_max=$r[0];
$filename=$id_max.".".$ext;
copy($map,"../file/$filename");
$sql="update tb_contact set map='$filename' where id_con='$id_max'";
mysql_db_query($dbname,$sql);
}
if($result) {
echo "<center><font size=\"3\" face='MS Sans Serif'><b>บันทึกข้อมูลกิจกรรมเรียบร้อย</b></font></center>";
}
else{echo"บันทึกข้อมูลลงฐานข้อมูลไม่สำเร็จ";}
?>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2011-06-03 00:14:32 |
By :
badtzyui |
View :
944 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 01
|