/var/www/globavet.com/webadmin/aboutus_add.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
<?php 
require 'check_login.php';
if (
$logged_in <> 1) {
    
header('Location: login.php');
    return;
}
else
{
require(
"configure.php");

$pid            $_POST["pid"];
$title_en        htmlspecialchars($_POST["title_en"],ENT_QUOTES);
$title_tc        htmlspecialchars($_POST["title_tc"],ENT_QUOTES);
$levelnum        $_POST["levelnum"];
$Sort            $_POST["sort"];
$desc_en        preg_replace("/'/","\'",$_POST["desc_en"]);
$desc_tc        preg_replace("/'/","\'",$_POST["desc_tc"]);

//print_r($_POST); 

$sql "select max(aboutusid) as maxid from aboutus ";
$result=mysql_query($sql);
$row mysql_fetch_array($result,MYSQL_ASSOC);
$aboutusid $row{maxid}+1;


if (
$Sort == '' || $Sort == '0') {
    
$sql "select max(sort) as maxid from aboutus WHERE parentid=".$pid." ";
    
$result=mysql_query($sql);
    
$row mysql_fetch_array($result,MYSQL_ASSOC);
    
$Sort $row{maxid}+1;
}
if( 
mysql_num_rows(mysql_query("SELECT aboutusid FROM aboutus WHERE parentid=".$pid." AND sort=$Sort ")) > 0){
    
mysql_query("UPDATE aboutus SET sort= Sort+1 WHERE parentid=".$pid." AND sort >=$Sort ");
}

$sql "insert into aboutus (aboutusid, parentid, levelnum, title_en, title_tc, desc_en, desc_tc, sort) 
        values ('
$aboutusid', '$pid', '$levelnum', '$title_en', '$title_tc', '$desc_en', '$desc_tc', '$Sort')";
mysql_query($sql);
if( 
mysql_errno() > ){
    echo 
'Add About Us Error:<br />'mysql_error() .'<br />SQL: '$sql;
    exit;
}

mysql_close($dbh);

header("Location: aboutus_index.php?pid=$pid&msg=Add Successful");
}
?>