|
|
|
พี่ๆคะ รบกวนดูโค๊ดให้หน่อยนะคะ อัพรูปลงฐานข้อมูลของ appsev ไม่ได้ค่ะ ติดมาหลายวันแล้ว |
|
|
|
|
|
|
|
ลองให้เพื่อนที่เก่งๆไล่โค๊ดให้ดู เพื่อนก็ช่วยไม่ได้ค่ะ เลยรบกวนอีกทีนะคะ ติดตรงนี้ที่เดียวก็จะเสร็จแล้วค่ะ
คือมันอัพโหลดรูปลงฐานข้อมูลใน appserv ไม่ได้ค่ะ รบกวนดูโค๊ดให้หน่อยนะคะ
หน้าฟอร์มรับค่าไฟล์และข้อมูล (PHP)
<? @ session_start();
?>
<!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>
<title>Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
background-color: #CCCCCC;
}
a:link {
color: #FF9900;
text-decoration: none;
}
a:visited {
color: #FF6633;
text-decoration: none;
}
a:hover {
color: #FFCC66;
text-decoration: none;
}
a:active {
color: #FF9900;
text-decoration: none;
}
.style1 {
color: #FF0000;
font-weight: bold;
}
.style2 {color: #660000}
-->
</style></head>
<body>
<?
include( "../config.php");
$sql2 = " SELECT CategoryID
,CategoryName
FROM room_category";
$result2 = mysql_query($sql2, $Connect) or die(mysql_error());
if($_GET["RoomID"] != "")
{
$sql1 = " SELECT r.RoomID
,r.RoomName
,r.RoomPrice
,rc.CategoryID
,rc.CategoryName
,r.RoomDescription
,r.RoomPicture
FROM room r
INNER JOIN room_category rc
ON r.CategoryID = rc.CategoryID
WHERE RoomID = ".$_GET["RoomID"] ;
$result1 = mysql_query($sql1, $Connect) or die(mysql_error());
while($row1 = mysql_fetch_array($result1))
{
$RoomID = $row1['RoomID'] ;
$RoomName = $row1['RoomName'] ;
$RoomPrice = $row1['RoomPrice'] ;
$RoomDescription = $row1['RoomDescription'] ;
$RoomPicture = $row1['RoomPicture'] ;
}
}
else
{
$id ="";
}
?>
<form id="addroom" enctype="multipart/form-data" name="addroom" method="post" action="addroom_save_action.php<? echo "?edit=$id"?>">
<table width="1000" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td colspan="4"><a href="Manage_Admin.php"><img src="../images/aaa.jpg" width="228" height="105" border="0" /></a> </td>
</tr>
<tr>
<td bgcolor="#666666"> </td>
</tr>
<tr>
<td colspan="4" bgcolor="#FFFFFF"> <div align="center"><span class="AdminText style2" ><strong>เพิ่มรายการห้อง</strong></span></div>
<table width="929" border="0">
<tr>
<th width="75" scope="col"> </th>
<th width="844" scope="col"> </th>
</tr>
<tr>
<th scope="row"> </th>
<td align="left"><table width="783" border="0" align="center" cellpadding="0" cellspacing="1" class="AdminText">
<tr>
<td width="96">ชื่อห้อง *</td>
<td width="660">
<div align="left">
<input name="txtRoomName" type="text" id="txtRoomName" value="<?=$RoomName; ?>" size="50"/>
<input name="hiddenRoomID" type="hidden" id="hiddenRoomID" value="<?=$RoomID; ?>" />
</div></td>
</tr>
<tr>
<td><div align="left">ราคา *</div></td>
<td>
<div align="left">
<input name="txtRoomPrice" onKeyPress="return checkIt(event)" type="text" id="txtRoomPrice" value="<?=$RoomPrice?>" size="50"/>
</div></td></tr> <tr>
<td><div align="left">ประเภท</div></td>
<td> <div align="left"><select id="cboRoom_category" name="cboRoom_category">
<option>--- เลือก ---</option>
<?
while($row2 = mysql_fetch_array($result2)){
?>
<option value="<?=$row2['CategoryID'];?>" ><?=$row2['CategoryName'];?></option>
<?
}
?>
</select>
</div></td></tr>
<tr>
<td><div align="left">รูป *</div></td>
<td><input name="fileUpload" type="file" value="<?=$PicEdit?>" id="Pic_path" size="50"/>
<?
if($_GET["edit"] != "")
{
echo "<img width=\"50\" src=\"$PicEdit\">";
}
?>
<input type="hidden" name="Pic_path" value="<?=$PicEdit?>" id="Pic_path" /></td>
</tr>
<tr>
<td align=""> </td>
<td><span class="style1">**รูปต้องเป็นไฟล์ JPG, JPEG เท่านั้น </span></td>
</tr>
<tr>
<td align="">รายละเอียด</td>
<td>
<div align="left">
<textarea name="txtDescription" cols="55" rows="5" id="txtDescription" ><?=$RoomDescription; ?></textarea>
</div></td>
</tr>
<tr>
<td> </td>
<td><div align="left"></div></td>
</tr>
</table></td>
</tr>
<tr>
<th scope="row"> </th>
<td><div align="center">
<input type="submit" name="saveproduct" id="saveproduct" value="ตกลง" />
<input type="reset" name="cancleproduct" id="cancleproduct" value="ยกเลิก" onclick="parent.location.href='../admin/edit_room.php'" />
</div></td>
</tr>
<tr>
<th scope="row"><div align="center"></div></th>
<td><div align="center"><a href="../admin/edit_room.php"><img src="../images/Back.png" width="15" height="15" /> กลับไปหน้าแก้ไข</a></div></td>
</tr>
</tr>
</table>
<br />
<br />
</form>
<?
mysql_close($Connect); //ปิดการติดต่อฐานข้อมูล
?>
</body>
</html>
อันนี้เป็นหน้าประมวลผลค่ะ
หน้าการประมวลผล (PHP)
<? session_start();
include( "../config.php");
if($_POST["hiddenRoomID"] != "")
{
$_POST["hiddenRoomID"];
$SQLUpdate = " UPDATE room
SET `RoomName` = '".$_POST["txtRoomName"]."'
, `RoomPrice` = '".$_POST["txtRoomPrice"]."'
, `CategoryID` = '".$_POST["cboRoom_category"]."'
, `RoomDescription` = '".$_POST["txtDescription"]."'
WHERE RoomID = '".$_POST["hiddenRoomID"]."'";
$Result1 = mysql_query($SQLUpdate);
if( $_FILES["file"]["name"] != "" ){
$SQLUpdate = " UPDATE room
SET `RoomPicture` = '".$_FILES["file"]["name"]."'
WHERE RoomID = '".$_POST["hiddenRoomID"]."'";
move_uploaded_file($_FILES["file"]["tmp_name"],"../Imageroom/".$_FILES["file"]["name"]);
$Result1 = mysql_query($SQLUpdate);
}
}
else
{
$insertSQL = "INSERT INTO room (
`RoomName`
, `RoomPrice`
, `CategoryID`
, `RoomPicture`
, `RoomDescription`
)VALUES(
'".$_POST["txtRoomName"]."'
, '".$_POST["txtRoomPrice"]."'
, '".$_POST["cboRoom_category"]."'
, '".$_FILES["file"]["name"]."'
, '".$_POST["txtDescription"]."'
) ";
move_uploaded_file($_FILES["file"]["tmp_name"],"../Imageroom/".$_FILES["file"]["name"]);
$result1 = mysql_query($insertSQL, $Connect) or die(mysql_error());
}
echo"<meta http-equiv='refresh' content='0 ;URL = edit_room.php '>";
?>
รบกวนพี่ๆผู้รู้ด้วยนะคะ ขอบคุณมากๆค่ะ
Tag : PHP
|
|
|
|
|
|
Date :
2013-08-20 03:06:54 |
By :
redkimono |
View :
684 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|