/var/www/c-c.com.hk/webadmin/contact_modify.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php require_once("configure.php");
 
$contactid             $_POST["contactid"];
$contacttitleen        htmlspecialchars($_POST["contacttitleen"],ENT_QUOTES);
$contactdescen        preg_replace("/'/","\'",$_POST["contactdescen"]);
$nowdate             date("Y-m-d H:i:s");
//print_r($_POST);

if ($_FILES['contactimage']['name'] <> '')
{
    if ((
$_FILES["contactimage"]["type"] == "image/bmp") || ($_FILES["contactimage"]["type"] == "image/BMP") || ($_FILES["contactimage"]["type"] == "image/gif") || ($_FILES["contactimage"]["type"] == "image/GIF") || ($_FILES["contactimage"]["type"] == "image/jpg") || ($_FILES["contactimage"]["type"] == "image/JPG") || ($_FILES["contactimage"]["type"] == "image/jpeg") || ($_FILES["contactimage"]["type"] == "image/JPEG") || ($_FILES["contactimage"]["type"] == "image/pjpeg") || ($_FILES["contactimage"]["type"] == "image/PJEG") || ($_FILES["contactimage"]["type"] == "image/png") || ($_FILES["contactimage"]["type"] == "image/x-png") || ($_FILES["contactimage"]["type"] == "image/PNG") || ($_FILES["contactimage"]["type"] == "image/X-PNG"))
    {
        
$filename=$_FILES['contactimage']['name'];
        
preg_match("/\.([^\.]+)$/"$filename$file_ext);
            
        
copy ($_FILES['contactimage']['tmp_name'], "../uploadfile/contactcover.".$file_ext[1]) 
            or die (
"Could not copy the file: Contact Image");
        
        
$contactimage     "contactcover.".$file_ext[1];
        
$contactimage    htmlspecialchars($contactimage,ENT_QUOTES);
      }
    else
      {
      
// upload error
      
?>
        <script language="javascript">
        alert("Files must be BMP, JPEG, GIF, or PNG");
        history.back();
        </script>
     <?php
     
exit;
     }

}
else
{
    
$contactimage "";
}

// Modify 
$sql "update contact set contacttitleen='$contacttitleen', contactdescen='$contactdescen', modifyday='$nowdate', cmsloginid='".$_SESSION['cmsloginid']."' ";
if (
$contactimage <> '')
    
$sql .= ", contactimage='$contactimage' ";
$sql .= " where contactid="$contactid ." ";
mysql_query($sql);

if( 
mysql_errno() > ){
    echo 
'Modify Contact Us Error:<br />'mysql_error() .'<br />SQL: '$sql;
    exit;
}

mysql_close($dbh);

header("Location: contact_modifyform.php?id=$contactid&msg=Modify Successful");
?>