 |
|
พี่ช่วยหน่อยไม่รูทามไมภาพไม่ลงในfolderและชื่อภาพก็ไม่ลงฐานอะ
หน้าedit
Code (PHP)
<td width="240" bgcolor="#F5F5F5" class="narmal2Bold"><div align="right" class="style16">
<div align="right">Picture : </div>
</div></td>
<td colspan="2" align="center" bgcolor="#F5F5F5" class="style14">
<p>
<? if(empty($his['Images_Connect']))echo "<img src='images_connector/noavatar.gif' width='90' height='100'>" ;
else echo "<img src='images_connector/".$his['Images_Connect']."' width='90' height='100'>";?>
</p>
<p><span class="head13Red"><font color="#FF0000" size="2" class="head13Red">อัพโหลดภาพใหม่.gif หรือ .jpg</font>
<input type="hidden" name="Max_size" value="50000" />
</span>
<input name="Images_Con" type="file" id="Images_Con" size="20"/>
</p></td>
หน้าUpdate
Code (PHP)
<?
$history = mysql_query("select Map_Sc,Images_Connect from school where ID_Sc = '$_SESSION[ID_Sc]'");
?>
<table width="653" border="0" cellspacing="1" cellpadding="1" style="table-layout: fixed;" >
<tr>
<td width="649">
<?
if($_SESSION[ID_Type_Sc]=='01')
$type_school="โรงเรียนประถมศึกษา ชายล้วน";
if($_SESSION[ID_Type_Sc]=='02')
$type_school="โรงเรียนประถมศึกษา หญิงล้วน";
if($_SESSION[ID_Type_Sc]=='03')
$type_school="โรงเรียนประถมศึกษา";
if($_SESSION[ID_Type_Sc]=='04')
$type_school="โรงเรียนอนุบาล";
if($_SESSION[ID_Type_Sc]=='05')
$type_school="โรงเรียนมัธยมศึกษา ชายล้วน";
if($_SESSION[ID_Type_Sc]=='06')
$type_school="โรงเรียนมัธยมศึกษา หญิงล้วน";
if($_SESSION[ID_Type_Sc]=='07')
$type_school="โรงเรียนมัธยมศึกษา";
?>
<?
$date = date("U");
$ID_Type_Sc=$_POST["ID_Type_Sc"];
$Name_Sc = $_POST["Namesc"];
$headmaster=$_POST["headmaster"];
$headgroup=$_POST["headgroup"];
$headsection=$_POST["headsection"];
$connect=$_POST["connect"];
$Street_Sc=$_POST["Street_Sc"];
$District_Sc=$_POST["District_Sc"];
$Alley_Sc=$_POST["Alley_Sc"];
$District_Sc=$_POST["District_Sc"];
$Boundary_Sc=$_POST["Boundary_Sc"];
$Province_Sc=$_POST["Province_Sc"];
$Tel_Sc=$_POST["Tel_Sc"];
$Tel_connect=$_POST["Tel_connect"];
$Fax_Sc=$_POST["Fax_Sc"];
$Email_Sc=$_POST["Email_Sc"];
while($his=mysql_fetch_array($history)){
$old_map= $his[0];
if(!empty($_POST["Map_School"])){
$Map_School=$_POST["Map_School"];
if($Map_School != "") {
if(!empty($his[0])){
$file1="images_school/".$his[0];
unlink($file1); }
$type = getimagesize($Map_School); //หาประเภทของรูปภาพ
if($type[2] == 1) { //เมื่อรูปภาพเป็นชนิด gif
$image = $date."_img.gif";
} else if($type[2] == 2) { //เมื่อรูปภาพเป็นชนิด jpg
$image = $date."_img.jpg";
}
copy($Map_School, "images_school/$image"); //ก๊อปปี้รูปภาพไปยังโพลเดอร์ images
chmod("images_school/$image", 0664);
}
$Map_School=$image;
}
$old_images= $his[1];
}
if(!empty($_POST["Images_Con"])){
$Images_Con=$_POST["Images_Con"];
if($Images_Con != "") {
// echo $_SESSION[Images_Connect]."<br>";
if(!empty($his[1])){
$file2="images_connector/".$his[1];
unlink($file2);}
$type = getimagesize($Images_Con); //หาประเภทของรูปภาพ
if($type[2] == 1) { //เมื่อรูปภาพเป็นชนิด gif
$image = $date."_img.gif";
} else if($type[2] == 2) { //เมื่อรูปภาพเป็นชนิด jpg
$image = $date."_img.jpg";
}
copy($Images_Con, "images_connector/$image"); //ก๊อปปี้รูปภาพไปยังโพลเดอร์ images
chmod("images_connector/$image", 0664);
}
$Images_Con=$image;
}
$_SESSION[ID_Type_Sc]=$ID_Type_Sc;
$_SESSION[Name_Sc]= $Name_Sc;
$_SESSION[headmaster]=$headmaster;
$_SESSION[headgroup]=$headgroup;
$_SESSION[headsection]=$headsection;
$_SESSION[connect]=$connect;
$_SESSION[Street_Sc]=$Street_Sc;
$_SESSION[Alley_Sc]=$Alley_Sc;
$_SESSION[District_Sc]=$District_Sc;
$_SESSION[Boundary_Sc]=$Boundary_Sc;
$_SESSION[Province_Sc]=$Province_Sc;
$_SESSION[Tel_Sc]=$Tel_Sc;
$_SESSION[Tel_connect]=$Tel_connect;
$_SESSION[Fax_Sc]=$Fax_Sc;
$_SESSION[Email_Sc]=$Email_Sc;
//echo "New images is ".$_SESSION[Images_Connect]."<br>";
//echo "New map is ".$_SESSION[Map_Sc]."<br>";
//echo "Old map is ".$old_map."<br>";
//echo "Old images is ".$old_images."<br>";
$pass=$_POST["Password"];
$ID_Sc=$_SESSION[ID_Sc];
$password=md5($pass);
if(($Map_School!="" or !empty($Map_School)) and ($Images_Con!="" or !empty($Images_Con)) ){
$sql="UPDATE School SET ID_Type_Sc = '".$ID_Type_Sc."' ,Name_Sc='".$Name_Sc."' ,headmaster = '".$headmaster."' , headgroup='".$headgroup."' , headsection='".$headsection."' , connect='".$connect."' , Street_Sc='".$Street_Sc."' , District_Sc='".$District_Sc."' , Alley_Sc='".$Alley_Sc."', Boundary_Sc='".$Boundary_Sc."' , Province_Sc='".$Province_Sc."' , Tel_Sc='".$Tel_Sc."' , Tel_connect='".$Tel_connect."' ,Fax_Sc='".$Fax_Sc."' , Email_Sc='".$Email_Sc."' , Password='".$password."' , Map_Sc='".$Map_School."' , Images_Connect='".$Images_Con."' WHERE ID_Sc ='$_SESSION[ID_Sc]'";
$_SESSION[Map_Sc]=$Map_School;
$_SESSION[Images_Connect]=$Images_Con;
}
if(($Map_School=="" or empty($Map_School)) and ($Images_Con=="" or empty($Images_Con))){
//echo $ID_Type_Sc.','.$Name_Sc.','.$headmaster.','.$headgroup.','.$headsection.','.$connect.','.$Street_Sc.','.$District_Sc.','.$Alley_Sc.','.$Boundary_Sc.','.$Province_Sc;
$sql="UPDATE School SET ID_Type_Sc = '".$ID_Type_Sc."' , Name_Sc='".$Name_Sc."' ,headmaster = '".$headmaster."' , headgroup='".$headgroup."' , headsection='".$headsection."' , connect='".$connect."' , Street_Sc='".$Street_Sc."' , District_Sc='".$District_Sc."' , Alley_Sc='".$Alley_Sc."', Boundary_Sc='".$Boundary_Sc."' , Province_Sc='".$Province_Sc."' , Tel_Sc='".$Tel_Sc."' , Tel_connect='".$Tel_connect."' ,Fax_Sc='".$Fax_Sc."' , Email_Sc='".$Email_Sc."' , Password='".$password."' , Map_Sc='".$old_map."' , Images_Connect='".$old_images."' WHERE ID_Sc ='$_SESSION[ID_Sc]'";
$_SESSION[Map_Sc]=$old_map;
$_SESSION[Images_Connect]=$old_images;
}
if(($Map_School!="" or !empty($Map_School)) and ($Images_Con=="" or empty($Images_Con))){
$sql="UPDATE School SET ID_Type_Sc = '".$ID_Type_Sc."' ,Name_Sc='".$Name_Sc."' , headmaster = '".$headmaster."' , headgroup='".$headgroup."' , headsection='".$headsection."' , connect='".$connect."' , Street_Sc='".$Street_Sc."' , District_Sc='".$District_Sc."' , Alley_Sc='".$Alley_Sc."', Boundary_Sc='".$Boundary_Sc."' , Province_Sc='".$Province_Sc."' , Tel_Sc='".$Tel_Sc."' , Tel_connect='".$Tel_connect."' ,Fax_Sc='".$Fax_Sc."' , Email_Sc='".$Email_Sc."' , Password='".$password."' , Map_Sc='".$Map_School."' , Images_Connect='".$old_images."' WHERE ID_Sc ='$_SESSION[ID_Sc]'";
$_SESSION[Map_Sc]=$Map_School;
$_SESSION[Images_Connect]=$old_images;
}
if(($Map_School=="" or empty($Map_School)) and ($Images_Con!="" or !empty($Images_Con))){
$sql="UPDATE School SET ID_Type_Sc = '".$ID_Type_Sc."' , headmaster = '".$headmaster."' , headgroup='".$headgroup."' , headsection='".$headsection."' , connect='".$connect."' , Street_Sc='".$Street_Sc."' , District_Sc='".$District_Sc."' , Alley_Sc='".$Alley_Sc."', Boundary_Sc='".$Boundary_Sc."' , Province_Sc='".$Province_Sc."' , Tel_Sc='".$Tel_Sc."' , Tel_connect='".$Tel_connect."' ,Fax_Sc='".$Fax_Sc."' , Email_Sc='".$Email_Sc."' , Password='".$password."' , Map_Sc='".$old_map."' , Images_Connect='".$Images_Con."' WHERE ID_Sc ='$_SESSION[ID_Sc]'";
$_SESSION[Map_Sc]=$old_map;
$_SESSION[Images_Connect]=$Images_Con;
}
//echo $sql."<br>";
//echo $pass."<br>";
$result=mysql_query ($sql);
if($result){ ?>
<center>
<span class="narmal2Bold">แก้ไขข้อมูลสำเร็จแล้ว <br>
<a href="profile_school.php">คลิกที่นี่ เพื่อดูรายละเอียด</a></span>
</center>
<?
}else{
echo"<center>แก้ไขข้อมูลไม่สำเร็จ กรุณากลับสู่หน้าหลัก<br><a href=\"index_school.php\">คลิกที่นี่ เพื่อกลับสู่หน้าหลัก</a></center>";
}?></td>
</tr>
</table>
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
2010-01-15 10:10:39 |
By :
LuckyStar |
View :
801 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |