/var/www/(Del)asld.org.hk/webadmin/historyadd.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
<?php
    
require("configure.php");

    if (!isset(
$_SESSION["cmslogin"])) {
        
header("Location: login.php");
        exit;
    }

    
$historycat   htmlspecialchars($_POST["historycat"], ENT_QUOTES);
    
$historytopic htmlspecialchars($_POST["historytopic"], ENT_QUOTES);
    
$historydate  htmlspecialchars($_POST["historydate"], ENT_QUOTES);

    if (
$_FILES['historyfile']['name'] <> '') {
        
copy($_FILES['historyfile']['tmp_name'], "historyfile/" $historyid $_FILES['historyfile']['name'])
        or die (
"Could not copy");

        
$historyfile $historyid $_FILES['historyfile']['name'];

    } else {
        
$historyfile "";
    }


    
$sql "select max(historyid) as maxid ";
    
$sql .= "from history";
    
$result    mysql_query($sql);
    
$row       mysql_fetch_array($resultMYSQL_ASSOC);
    
$historyid $row{maxid} + 1;

    
$sql "insert into history (historyid, historycat, historytopic, historydate, historyfile) values ('$historyid', '$historycat', '$historytopic', '$historydate', '$historyfile')";
//echo $sql;
    
mysql_query($sql);
    
mysql_close($dbh);

    
header("Location: historyindex.php?msg=Add Successful");
?>