Preview: insertReport.php
Size: 1.84 KB
/home/www/idcceurope.com/www/idcceurope.com/insertReport.php
<?php
include("variable.php");
$my_con=mysql_connect($url,$user,$pass);
if(!$my_con){
die("Could not connect".mysql_error());
}
else{
mysql_select_db($database,$my_con);
$path = $_POST["path"];
$id = (int)$_POST["id"];
$tiemId = (int)$_POST["salon"];
$service = $_POST["service"];
$st='';
if(strlen($path)>0){
$temp = explode("\\",$path);
$n =count($temp);
$st = $temp[$n-1];
}
if(strcmp($service,"add")==0){
$sql = "SELECT * FROM anh_tiem WHERE id = $id";
$result = mysql_query($sql);
if(mysql_num_rows($result)>0){
$sql = "UPDATE anh_tiem set path = '$st', tiemId = $tiemId WHERE id = $id";
}
else{
$sql = "INSERT INTO anh_tiem (path,tiemId) VALUES ('$st',$tiemId)";
}
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if(!file_exists("slideshow/" . $_FILES["file"]["name"]))
{
move_uploaded_file($_FILES["file"]["tmp_name"],"slideshow/" . $_FILES["file"]["name"]);
}
}
}
else if(strcmp($service,"edit")==0){
if(strlen($path)>0){
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if(!file_exists("slideshow/" . $_FILES["file"]["name"]))
{
move_uploaded_file($_FILES["file"]["tmp_name"],"slideshow/" . $_FILES["file"]["name"]);
}
}
$sql = "UPDATE anh_tiem SET path = '$path',tiemId = $tiemId WHERE id = $id";
}
else{
$sql = "UPDATE anh_tiem SET tiemId = $tiemId WHERE id = $id";
}
}
else{
$sql = "DELETE FROM anh_tiem WHERE id = $id";
}
mysql_query($sql);
}
mysql_close($my_con);
//echo $sql;
header("Location: nhapanhtiem.php?salon=".$tiemId);
?>
Directory Contents
Dirs: 7 × Files: 56