logo-dohoalaptrinh

Trung tâm đào tạo đồ họa designtech

Chuyên lĩnh vực : đồ họa quảng cáo in ấn, thiết kế nội thất ngoại thất, phối cảnh, xây dựng, cơ khí

Trang chủ » series php hướng dẫn làm web bán hàng » Hướng dẫn làm web bán hàng bằng php từ a-z-phần 7
5/5 - (2 bình chọn)

Hướng dẫn làm web bán hàng bằng php từ a-z-phần 7

5/5 - (2 bình chọn)

Hướng dẫn làm web bán hàng bằng php từ a-z-phần 7

Phần này mình đi vào từng mục :
include_file(“cumchucnang/xuly_form/xuly_form.php”);

1.include_file(“cumchucnang/quanly_menu_doc/thuchien_them_leftmenu.php”);

[sourcecode language=”plain”]</pre>
<?php
chong_pha_hoai();
?>
<?php
if($_POST[‘chon_menu’]=="")
{
$tv="select * from thong_so where ma_so=’8’";
$tv_1=mysql_query($tv);
$tv_2=mysql_fetch_array($tv_1);
$rel="menu-".$tv_2[‘gia_tri’];
$t_1=$tv_2[‘gia_tri’]+1;
$up="UPDATE `thong_so` SET `gia_tri` = ‘$t_1’ WHERE `ma_so` = ‘8’";
//die($up);
mysql_query($up);
}
if(trim($_POST[‘url_dep’])!="")
{
$url_dep=$_POST[‘url_dep’];
}
else
{
$class_url_dep=new url_dep();
$url_dep=$class_url_dep->url_dep($_POST[‘txttd’]);
}
$_SESSION[‘dang’]=$_POST[‘dang’];
$_SESSION[‘chon_menu’]=$_POST[‘chon_menu’];
if($_POST[‘keywords’]=="")
{
$_POST[‘keywords’]=$_POST[‘txttd’];
}
$max_id_fff=max_id_fff("menu");
$sap_xep=$max_id_fff+1;
$sql = "
INSERT INTO `menu`
(
`id` ,
`ten`,
`thuoc_menu`,
`ten_en`,
`dang`,
`keywords`,
`description`,
`link`,
`rel`,
`sap_xep`,
`url_dep`
)
VALUES
(
NULL ,
‘$_POST[txttd]’,
‘$_POST[chon_menu]’,
‘$_POST[txttd_en]’,
‘$_POST[dang]’,
‘$_POST[keywords]’,
‘$_POST[description]’,
‘$_POST[link]’,
‘$rel’,
‘$sap_xep’,
‘$url_dep’
)";
if(trim($_POST[‘txttd’]) != "")
{
mysql_query($sql);
}
else
{
thongbao("Không được bỏ trống tiêu đề !");
}
?>
<pre>[/sourcecode]

2 include_file(“cumchucnang/quanly_menu_doc/thuchien_sua_leftmenu.php”);

[sourcecode language=”plain”]</pre>
<?php
chong_pha_hoai();
?>
<?php
if($_POST[‘tenmenu’] != "")
{
$url_dep=$_POST[‘url_dep’];
$update = "UPDATE `menu` SET `ten` = ‘$_POST[tenmenu]’,
`dang`=’$_POST[dang]’,
`link`=’$_POST[link]’,
`keywords`=’$_POST[keywords]’,
`description`=’$_POST[description]’,
`url_dep`=’$url_dep’

WHERE `id` =’$_GET[id_menu]’" ;
mysql_query($update);
}
?>
<pre>[/sourcecode]

3.include_file(“cumchucnang/quanly_dulieu/thuchien_them_sanpham_vao_leftmenu.php”);

[sourcecode language=”plain”]</pre>
<?php
chong_pha_hoai();
class class__kiem_tra_form_de_them_du_lieu
{

function chuoi_nhieu_hinh_anh()
{
$mang=getDirectoryList("../hinhanh_flash/upload_tam/");
// ham getDirectoryList :lay danh sach file trong thu muc , tra ve mang
$chuoi="";
for($i=0;$i<count($mang);$i++)
{
$chuoi=$chuoi.$mang[$i]."____";
}
if($chuoi=="____")
{
$chuoi="";
}
return $chuoi;
}
function them_vao_co_so_du_lieu_mot_dong(){
chong_90($ten_file_anh);
$c3="";
if($_FILES[‘up_hinh_1’][‘name’]!=""){chong_90($_FILES[‘up_hinh_1’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_1’][‘name’];}
if($_FILES[‘up_hinh_2’][‘name’]!=""){chong_90($_FILES[‘up_hinh_2’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_2’][‘name’];}
if($_FILES[‘up_hinh_3’][‘name’]!=""){chong_90($_FILES[‘up_hinh_3’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_3’][‘name’];}
if($_FILES[‘up_hinh_4’][‘name’]!=""){chong_90($_FILES[‘up_hinh_4’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_4’][‘name’];}
if($_FILES[‘up_hinh_5’][‘name’]!=""){chong_90($_FILES[‘up_hinh_5’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_5’][‘name’];}
if($_FILES[‘up_hinh_6’][‘name’]!=""){chong_90($_FILES[‘up_hinh_6’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_6’][‘name’];}
if($_FILES[‘up_hinh_7’][‘name’]!=""){chong_90($_FILES[‘up_hinh_7’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_7’][‘name’];}
if($_FILES[‘up_hinh_8’][‘name’]!=""){chong_90($_FILES[‘up_hinh_8’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_8’][‘name’];}
if($_FILES[‘up_hinh_9’][‘name’]!=""){chong_90($_FILES[‘up_hinh_9’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_9’][‘name’];}
if($_FILES[‘up_hinh_10’][‘name’]!=""){chong_90($_FILES[‘up_hinh_10’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_10’][‘name’];}
if($_FILES[‘up_hinh_11’][‘name’]!=""){chong_90($_FILES[‘up_hinh_11’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_11’][‘name’];}
if($_FILES[‘up_hinh_12’][‘name’]!=""){chong_90($_FILES[‘up_hinh_12’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_12’][‘name’];}
//if($_FILES[‘up_hinh_1’][‘name’]!=""){if(ereg(".php"))}
// ham empty_forder : lam rong thu muc
//$chuoi_nhieu_hinh_anh=$this->chuoi_nhieu_hinh_anh();
$_SESSION[‘size’]=trim($_POST[‘size’]);
$_SESSION[‘capdo’]=trim($_POST[‘capdo’]);
$ten_file_anh=$_FILES[‘uploadedfile’][‘name’];
$_POST[‘size’]=trim($_POST[‘size’]);
$_POST[‘mo_ta_ngan’]=nl2br($_POST[‘mo_ta_ngan’]);
if(trim($_POST[‘keywords’])==""){$_POST[‘keywords’]=trim($_POST[‘tieude’]);}
$max_id_fff=max_id_fff("dulieu");
$sap_xep=$max_id_fff+1;
if(trim($_POST[‘url_dep’])!="")
{
$url_dep=$_POST[‘url_dep’];
}
else
{
$class_url_dep=new url_dep();
$url_dep=$class_url_dep->url_dep($_POST[‘tieude’]);
}
//die($url_dep);
$chuoi_dulieu_themvao="
INSERT INTO `dulieu`
(
`id` , `tieu_de` , `gia` ,`loai_gia`, `hinh_anh` ,
`noi_dung` , `thuoc_menu`,`trang_thai`,`khuyen_mai`,`nhieu_hinh_anh`,
`tieu_de__en`,`noi_dung__en` ,`trang_thai__en`,`khuyen_mai__en`,`size`,`keywords`,`description`,`khoi_luong`,`mo_ta_ngan`
, `sap_xep`,`url_dep`
)
VALUES
(
NULL , ‘$_POST[tieude]’, ‘$_POST[giaban]’,’$_POST[loai_gia]’, ‘$ten_file_anh’,
‘$_POST[noidung]’, ‘$_POST[capdo]’,’$_POST[trang_thai]’,’$_POST[khuyen_mai]’,’$c3′,
‘$_POST[tieude_en]’,’$_POST[noidung_en]’,’$_POST[trang_thai__en]’,’$_POST[khuyen_mai__en]’,’$_POST[size]’,
‘$_POST[keywords]’,’$_POST[description]’,’$_POST[khoi_luong]’,’$_POST[mo_ta_ngan]’
,’$sap_xep’,’$url_dep’
);";
//die($chuoi_dulieu_themvao);

mysql_query($chuoi_dulieu_themvao);
$tv="select max(id) from dulieu";
$tv_1=mysql_query($tv);
$tv_2=mysql_fetch_row($tv_1);
$id=$tv_2[0];
$url_dep=$url_dep."-".$id;
$up="UPDATE `dulieu` SET `url_dep` = ‘$url_dep’ WHERE `id` =’$id’;";
mysql_query($up);
//die($up);
$thu_muc="../hinhanh_flash/sanpham/$id/";
mkdir($thu_muc);
chmod($thu_muc, 0777);
create_file($thu_muc."index.html");
if($_FILES[‘up_hinh_1’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_1’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_1’][‘name’]);}
if($_FILES[‘up_hinh_2’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_2’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_2’][‘name’]);}
if($_FILES[‘up_hinh_3’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_3’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_3’][‘name’]);}
if($_FILES[‘up_hinh_4’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_4’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_4’][‘name’]);}
if($_FILES[‘up_hinh_5’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_5’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_5’][‘name’]);}
if($_FILES[‘up_hinh_6’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_6’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_6’][‘name’]);}
if($_FILES[‘up_hinh_7’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_7’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_7’][‘name’]);}
if($_FILES[‘up_hinh_8’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_8’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_8’][‘name’]);}
if($_FILES[‘up_hinh_9’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_9’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_9’][‘name’]);}
if($_FILES[‘up_hinh_10’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_10’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_10’][‘name’]);}
if($_FILES[‘up_hinh_11’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_11’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_11’][‘name’]);}
if($_FILES[‘up_hinh_12’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_12’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_12’][‘name’]);}
//mkdir("$tentaikhoan");
//chmod("$tentaikhoan", 0777);

}
function upload_anh(){
$ten_file_anh=$_FILES[‘uploadedfile’][‘name’];
$duongdan_upload_anh="../hinhanh_flash/sanpham/$ten_file_anh";
chong_90($ten_file_anh);
move_uploaded_file($_FILES[‘uploadedfile’][‘tmp_name’],$duongdan_upload_anh);
}
function them_du_lieu(){
$this->upload_anh();
$this->them_vao_co_so_du_lieu_mot_dong();
}
function kiem_tra_tieu_de_form(){
if($_POST[‘tieude’]!="")
{
$this->them_du_lieu();
}
else
{
thongbao("Không được bỏ trống tiêu đề");
}
}
function xacdinh_upload_khong_trung_ten_anh(){
$ten_file_anh=$_FILES[‘uploadedfile’][‘name’];
$chuoi_tv="select count(*) from dulieu where hinh_anh in (‘$ten_file_anh’)";
//thongbao($chuoi_tv);
$mang_so_dem_so_anh=mysql_fetch_row(mysql_query($chuoi_tv));
$soanh_demduoc=$mang_so_dem_so_anh[0];
if($soanh_demduoc==0)
{
return "co";
}
else
{
if($ten_file_anh=="")
{
return "co";
}
else
{
return "khong";
}
}
}
function kiem_tra_hinh_anh_form(){
$xacdinh_upload_khong_trung_ten_anh=$this->xacdinh_upload_khong_trung_ten_anh();
if($xacdinh_upload_khong_trung_ten_anh=="co")
{
$this->kiem_tra_tieu_de_form();
}
else
{
thongbao("File ảnh này trùng tên với tên file ảnh đã up len , xin bạn hãy đổi tên file ảnh !");
}
}
function kiem_tra_form_de_them_du_lieu()
{
if(isset($_POST[‘them_dulieu_menu_doc’]))
//neu co ton tai bien $_POST[‘them_dulieu_menu_doc’] thi moi duoc kiem tra hinh anh form gui di co hop le hay khong
{
$this->kiem_tra_hinh_anh_form();
//neu co ton tai bien $_POST[‘them_dulieu_menu_doc’] thi moi duoc kiem tra hinh anh form gui di co hop le hay khong
}
}
}
$class__kiem_tra_form_de_them_du_lieu=new class__kiem_tra_form_de_them_du_lieu;
$class__kiem_tra_form_de_them_du_lieu->kiem_tra_form_de_them_du_lieu();
//echo ereg("a","abc");
?>
<pre>[/sourcecode]

4 . include_file(“cumchucnang/quanly_dulieu/thuchien_sua_sanpham_left_menu.php”);

[sourcecode language=”plain”]</pre>
<?php
chong_pha_hoai();
//thongbao("vao day hahaahah");
//thongbao($_POST[‘hd_dkl’]);
//thongbao("vao day");exit();
?>
<?php
class class__kiemtra_va_sua_du_lieu
{
function nhieu_hinh_anh()
{
$chuoi = "";
for($i=0;$i<$_POST[‘hd_dkl’]-1;$i++)
{
$o_1=$i+1;
$name_1 = "nhieu_hinh_abc__$o_1";
$name_2 = "hidden_nhieu_hinh_abc__$o_1";
$name_3 = "tuy_chon_abc__$o_1";
$post_1 = $_FILES[$name_1][‘name’];
$post_2 = $_POST[$name_2];
$post_3 = $_POST[$name_3];
if($post_3!="xoa")
{
if($post_1!="")
{
$chuoi = $chuoi.$post_1."____";
}
else
{
$chuoi = $chuoi.$post_2."____";
}
}
}
$mang=getDirectoryList("../hinhanh_flash/upload_tam/");
// ham getDirectoryList :lay danh sach file trong thu muc , tra ve mang
if(count($mang)!=0)
{
for($i=0;$i<count($mang);$i++)
{
$chuoi=$chuoi.$mang[$i]."____";
}
}

return $chuoi;
}
function xacdinh_ten_anh_update()
{
$ten_file_anh=$_FILES[‘uploadedfile’][‘name’];
if($ten_file_anh!="")
{
return $ten_file_anh;
}
else
{
return $_POST[‘ten_anh’];
}

}
function sua_mot_dong_mysql()
{
//$nhieu_hinh_anh=$this->nhieu_hinh_anh();
//$this->up_nhieu_hinh();
//$this->up_lai_nhieu_hinh();
$c3="";
if(trim($_POST[‘xoa_anh_1’])=="khong"){if($_FILES[‘up_hinh_1’][‘name’]!=""){chong_90($_FILES[‘up_hinh_1’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_1’][‘name’];}else {if(trim($_POST[‘hd_up_hinh_1’])!=""){$c3=$c3."____".$_POST[‘hd_up_hinh_1’];}}}
if(trim($_POST[‘xoa_anh_2’])=="khong"){if($_FILES[‘up_hinh_2’][‘name’]!=""){chong_90($_FILES[‘up_hinh_2’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_2’][‘name’];}else {if(trim($_POST[‘hd_up_hinh_2’])!=""){$c3=$c3."____".$_POST[‘hd_up_hinh_2’];}}}
if(trim($_POST[‘xoa_anh_3’])=="khong"){if($_FILES[‘up_hinh_3’][‘name’]!=""){chong_90($_FILES[‘up_hinh_3’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_3’][‘name’];}else {if(trim($_POST[‘hd_up_hinh_3’])!=""){$c3=$c3."____".$_POST[‘hd_up_hinh_3’];}}}
if(trim($_POST[‘xoa_anh_4’])=="khong"){if($_FILES[‘up_hinh_4’][‘name’]!=""){chong_90($_FILES[‘up_hinh_4’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_4’][‘name’];}else {if(trim($_POST[‘hd_up_hinh_4’])!=""){$c3=$c3."____".$_POST[‘hd_up_hinh_4’];}}}
if(trim($_POST[‘xoa_anh_5’])=="khong"){if($_FILES[‘up_hinh_5’][‘name’]!=""){chong_90($_FILES[‘up_hinh_5’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_5’][‘name’];}else {if(trim($_POST[‘hd_up_hinh_5’])!=""){$c3=$c3."____".$_POST[‘hd_up_hinh_5’];}}}
if(trim($_POST[‘xoa_anh_6’])=="khong"){if($_FILES[‘up_hinh_6’][‘name’]!=""){chong_90($_FILES[‘up_hinh_6’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_6’][‘name’];}else {if(trim($_POST[‘hd_up_hinh_6’])!=""){$c3=$c3."____".$_POST[‘hd_up_hinh_6’];}}}
if(trim($_POST[‘xoa_anh_7’])=="khong"){if($_FILES[‘up_hinh_7’][‘name’]!=""){chong_90($_FILES[‘up_hinh_7’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_7’][‘name’];}else {if(trim($_POST[‘hd_up_hinh_7’])!=""){$c3=$c3."____".$_POST[‘hd_up_hinh_7’];}}}
if(trim($_POST[‘xoa_anh_8’])=="khong"){if($_FILES[‘up_hinh_8’][‘name’]!=""){chong_90($_FILES[‘up_hinh_8’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_8’][‘name’];}else {if(trim($_POST[‘hd_up_hinh_8’])!=""){$c3=$c3."____".$_POST[‘hd_up_hinh_8’];}}}
if(trim($_POST[‘xoa_anh_9’])=="khong"){if($_FILES[‘up_hinh_9’][‘name’]!=""){chong_90($_FILES[‘up_hinh_9’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_9’][‘name’];}else {if(trim($_POST[‘hd_up_hinh_9’])!=""){$c3=$c3."____".$_POST[‘hd_up_hinh_9’];}}}
if(trim($_POST[‘xoa_anh_10’])=="khong"){if($_FILES[‘up_hinh_10’][‘name’]!=""){chong_90($_FILES[‘up_hinh_10’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_10’][‘name’];}else {if(trim($_POST[‘hd_up_hinh_10’])!=""){$c3=$c3."____".$_POST[‘hd_up_hinh_10’];}}}
if(trim($_POST[‘xoa_anh_11’])=="khong"){if($_FILES[‘up_hinh_11’][‘name’]!=""){chong_90($_FILES[‘up_hinh_11’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_11’][‘name’];}else {if(trim($_POST[‘hd_up_hinh_11’])!=""){$c3=$c3."____".$_POST[‘hd_up_hinh_11’];}}}
if(trim($_POST[‘xoa_anh_12’])=="khong"){if($_FILES[‘up_hinh_12’][‘name’]!=""){chong_90($_FILES[‘up_hinh_12’][‘name’]);$c3=$c3."____".$_FILES[‘up_hinh_12’][‘name’];}else {if(trim($_POST[‘hd_up_hinh_12’])!=""){$c3=$c3."____".$_POST[‘hd_up_hinh_12’];}}}

$thu_muc="../hinhanh_flash/sanpham/".$_GET[‘id_sp’]."/";
if(!is_dir($thu_muc))
{
mkdir($thu_muc);
chmod($thu_muc, 0777);
create_file($thu_muc."index.html");
}
if($_FILES[‘up_hinh_1’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_1’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_1’][‘name’]);}
if($_FILES[‘up_hinh_2’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_2’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_2’][‘name’]);}
if($_FILES[‘up_hinh_3’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_3’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_3’][‘name’]);}
if($_FILES[‘up_hinh_4’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_4’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_4’][‘name’]);}
if($_FILES[‘up_hinh_5’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_5’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_5’][‘name’]);}
if($_FILES[‘up_hinh_6’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_6’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_6’][‘name’]);}
if($_FILES[‘up_hinh_7’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_7’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_7’][‘name’]);}
if($_FILES[‘up_hinh_8’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_8’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_8’][‘name’]);}
if($_FILES[‘up_hinh_9’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_9’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_9’][‘name’]);}
if($_FILES[‘up_hinh_10’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_10’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_10’][‘name’]);}
if($_FILES[‘up_hinh_11’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_11’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_11’][‘name’]);}
if($_FILES[‘up_hinh_12’][‘name’]!=""){move_uploaded_file($_FILES[‘up_hinh_12’][‘tmp_name’],$thu_muc.$_FILES[‘up_hinh_12’][‘name’]);}

$_POST[‘mo_ta_ngan’]=nl2br($_POST[‘mo_ta_ngan’]);

include("cumchucnang/bien/bien.php");
$ten_anh=$this->xacdinh_ten_anh_update();

$url_dep=$_POST[‘url_dep’];
//die($url_dep);
$update="UPDATE `dulieu` SET `tieu_de` = ‘$_POST[tieude]’,
`$tb__dulieu__f__gia` = ‘$_POST[giaban]’,
`$tb__dulieu__f__loai_gia`=’$_POST[loai_gia]’,
`$tb__dulieu__f__hinh_anh` = ‘$ten_anh’,
`$tb__dulieu__f__noi_dung` = ‘$_POST[noidung]’ ,
`$tb__dulieu__f__trang_thai`=’$_POST[trang_thai]’,
`$tb__dulieu__f__khuyen_mai`=’$_POST[khuyen_mai]’,
`nhieu_hinh_anh`=’$c3′,
`tieu_de__en`=’$_POST[tieude_en]’,
`noi_dung__en`=’$_POST[noidung_en]’,
`trang_thai__en`=’$_POST[trang_thai__en]’,
`khuyen_mai__en`=’$_POST[khuyen_mai__en]’,
`khoi_luong`=’$_POST[khoi_luong]’,
`size`=’$_POST[size]’,
`keywords`=’$_POST[keywords]’,
`description`=’$_POST[description]’,
`mo_ta_ngan`=’$_POST[mo_ta_ngan]’,
`url_dep`=’$url_dep’

WHERE `$tb__dulieu__f__id` =’$_GET[id_sp]’;";
//die($update);
mysql_query($update);
$id=$_GET[‘id_sp’];
$url_dep=$url_dep."-".$id;
$up="UPDATE `dulieu` SET `url_dep` = ‘$url_dep’ WHERE `id` =’$id’;";
mysql_query($up);
//empty_forder("../hinhanh_flash/upload_tam/");
// ham empty_forder : lam rong thu muc
}
function upload()
{
chong_90($_FILES[‘uploadedfile’][‘name’]);
$ten_file_anh_1=$_FILES[‘uploadedfile’][‘name’];
$duongdan_upload_anh="../hinhanh_flash/sanpham/$ten_file_anh_1";
move_uploaded_file($_FILES[‘uploadedfile’][‘tmp_name’],$duongdan_upload_anh);
}
function kiemtra_tieude()
{
if($_POST[‘tieude’]!="")
{
$this->upload();
$this->sua_mot_dong_mysql();
}
else
{
thongbao("Không được bỏ trống tiêu đề");
}
}
function kiemtra_hinhanh__co_khong()
{
$ten_file_anh=$_FILES[‘uploadedfile’][‘name’];
if($ten_file_anh=="")
{
return "co";
}
else
{
$ten_file_anh=$_FILES[‘uploadedfile’][‘name’];
if($ten_file_anh=="")
{
$ten_file_anh="bo_trong";
}
$dem_anh=mysql_fetch_row(mysql_query("select count(*) from dulieu where hinh_anh in (‘$ten_file_anh’)"));
if($dem_anh[0]==0)
{
return "co";
}
else
{
return "khong";
}
}
}
function kiemtra_hinhanh()
{
$xuly_query_upload_anh=$this->kiemtra_hinhanh__co_khong();
if($xuly_query_upload_anh=="co")
{
$this->kiemtra_tieude();
}
else
{
thongbao("File ảnh này trùng tên với tên file ảnh đã up len , xin bạn hãy đổi tên file ảnh !");
}
trangtruoc();
}
function kiemtra_va_sua_du_lieu()
{
if(isset($_POST[‘sua_dulieu_menu_doc’]))
{
//echo "sua du lieu";
$this->kiemtra_hinhanh();
}
}
}
$class__kiemtra_va_sua_du_lieu=new class__kiemtra_va_sua_du_lieu;
$class__kiemtra_va_sua_du_lieu->kiemtra_va_sua_du_lieu();
?>
<pre>[/sourcecode]

5 . include_file(“cumchucnang/quanly_menu_ngang/thuchien_them_menu_ngang.php”);

[sourcecode language=”plain”]</pre>
<?php
chong_pha_hoai();
?>
<?php
$class_url_dep=new url_dep();
$url_dep=$class_url_dep->url_dep("Đỗ khắc luân ??? !@# a");
//echo $url_dep."<hr>";
if(trim($_POST[‘form_hd_555’])=="form_hd_555")
{
if($_POST[‘link’]=="san_pham")
{
$_SESSION[‘selected_159’]="selected";
$_SESSION[‘selected_160’]="selected";
$_SESSION[‘link_728’]="san_pham";
$loai_menu="san_pham";
$link="";
}
else
{
$_SESSION[‘selected_159’]="";
$_SESSION[‘selected_160’]="selected";
$_SESSION[‘link_728’]="";
$link=$_POST[‘link’];

}
//thongbao("ppppp");
$_SESSION[‘cdmnn’]=$_POST[‘capdo’];
$_SESSION[‘lmn’]=$_POST[‘lmn’];
$max_id_fff=max_id_fff("menu");
$sap_xep=$max_id_fff+1;
if(trim($_POST[‘url_dep’])!="")
{
$url_dep=$_POST[‘url_dep’];
}
else
{
$class_url_dep=new url_dep();
$url_dep=$class_url_dep->url_dep($_POST[‘txttd’]);
}
$sql = "INSERT INTO `menu` ( `id` , `ten` ,`ten_en`, `thuoc_menu` , `loai`,`link`,`vi_tri_menu`,`sap_xep`,`url_dep` )
VALUES (
NULL , ‘$_POST[txttd]’,’$_POST[txttd_en]’, ‘$_POST[capdo]’, ‘$loai_menu’,’$link’,’ngang’,’$sap_xep’,’$url_dep’
)";
//echo $sql." \$sql <br>";
//exit();
if(trim($_POST[‘txttd’]) != "")
{
mysql_query($sql);
}
else
{
//echo "Không được bỏ trống tiêu đề !";
thongbao("Không được bỏ trống tiêu đề !");
}
trangtruoc();
exit();
}
?>
<form action="" method="post">
<table border="0" id="er" width="970px" style="margin:6px 0px">
<tr>
<td colspan="2">
<h5><span style="font-size: 14pt;">Thêm menu ngang</span></h5>
</td>
</tr>
<tr>
<td width="150px"><b>Cấp Độ :</b></td>
<td>
<select name="capdo">
<option value=""><b>Cấp Đầu</b></option>
<?php

function option_cap_hai($id_menu,$nhandang)
{
$nhandang=$nhandang."     ";
include("cumchucnang/bien/bien.php");
$sql_2 = "select * from menu where thuoc_menu in(‘$id_menu’) order by id asc";
$query_2 = mysql_query($sql_2);
while($row_array = mysql_fetch_array($query_2))
{
$thuoc_menu=$row_array[‘thuoc_menu’];
$ten_menu=$row_array[‘ten’];
$id_menu=$row_array[‘id’];
if($_SESSION[‘cdmnn’]==$id_menu){$a="selected=’selected’";}else{$a="";}
echo "<option value=\"$id_menu\" $a >";
//echo "   ";
echo $nhandang;
echo "$ten_menu";
echo "</option>";
$sql_1 = "select count(*) from menu where thuoc_menu in(‘$id_menu’)";
$query_1 = mysql_query($sql_1);
$fetch_row = mysql_fetch_row($query_1);
if($fetch_row[0] != 0)
{
<h5><span style="font-size: 14pt;">option_cap_hai($id_menu,$nhandang);</span></h5>
}
}
}
$nhandang="";
$sql = "select * from menu where thuoc_menu in (”) and vi_tri_menu=’ngang’ order by id asc";
$query_left = mysql_query($sql);
while($row_left = mysql_fetch_array($query_left))
{
$ten_menu=$row_left[‘ten’];
$id_menu=$row_left[‘id’];
if($_SESSION[‘cdmnn’]==$id_menu){$a="selected=’selected’";}else{$a="";}
echo "<option value=\"$id_menu\" $a >";
echo "$ten_menu";
echo "</option>";
$sql_1 = "select count(*) from menu where thuoc_menu in(‘$id_menu’)";
$query_1 = mysql_query($sql_1);
$fetch_row = mysql_fetch_row($query_1);
if($fetch_row[0] != 0)
{
option_cap_hai($id_menu,$nhandang);
}
}

?>
</select>
</td>
</tr>
<tr>
<td><b>Tiêu Đề : </b></td>
<td><input type="text" name="txttd" size="50"/></td>
</tr>
<!–<tr>
<td><b>Loại menu : </b></td>
<td>
<select name="loai_menu">
<option value="nhieu_tin">Nhiều tin</option>
<option value="mot_tin">Một tin</option>
<option value="trang_chu">Trang chu</option>
<option value="lien_he">Liên hệ</option>
<option value="toanbo_sanpham">Sản phẩm</option>
</select>
</td>
</tr>–>
<tr>
<td><b>Loại menu : </b></td>
<td>
<?php
$link_hd="?thamso=xuat_mot_tin&id=108";
if($_SESSION[‘lmn’]=="?thamso=trang_chu"){$a_2="selected=’selected’";$link_hd="?thamso=trang_chu";}
if($_SESSION[‘lmn’]=="?thamso=tin_tuc"){$a_3="selected=’selected’";$link_hd="?thamso=tin_tuc";}
if($_SESSION[‘lmn’]=="?thamso=san_pham_moi"){$a_4="selected=’selected’";$link_hd="?thamso=san_pham_moi";}
if($_SESSION[‘lmn’]=="?thamso=lien_he"){$a_5="selected=’selected’";$link_hd="?thamso=lien_he";}
if($_SESSION[‘lmn’]=="san_pham"){$a_6="selected=’selected’";$link_hd="san_pham";}
?>
<script>
function h_jf9(vl)
{

document.getElementById(‘link’).value=vl;
if(vl=="?thamso=xuat_mot_tin&id=108")
{
var vl="?thamso=xuat_mot_tin&id="+document.getElementById(‘sl_o2’).value;
document.getElementById(‘link’).value=vl;
document.getElementById(‘id_bai_viet’).style.display="block";
}
else
{
<h5><span style="font-size: 14pt;">document.getElementById(‘id_bai_viet’).style.display="none";</span></h5>
}
//alert(vl);
}
function h_k12(vl)
{
//var gt_cu=document.getElementById(‘link’).value;
var gt_moi="?thamso=xuat_mot_tin&id="+vl;
document.getElementById(‘link’).value=gt_moi;
if(vl=="108")
{
document.getElementById(‘text_r9’).innerHTML="Hãy chọn 1 id để liên kết tới bài viết muốn sữa";
}
else
{
document.getElementById(‘text_r9′).innerHTML="<a href=’?thamso=quanly_dulieu_menu_ngang&sua_dulieu_menu_ngang=co&id_mnn="+vl+"’ target=’_blank’ class=’link_l88′ >Click vào đây để sữa bài viết có id là <b style=’font-size:20px’>"+vl+"</b></a>";
}
//alert(gt_moi);
}
</script>
<select onchange="h_jf9(this.value);" name="lmn" >
<option value="?thamso=xuat_mot_tin&id=108" >Bài viết</option>
<option value="san_pham" <?php echo $a_6; ?> >Sản phẩm</option>
<option value="?thamso=trang_chu" <?php echo $a_2; ?> >Trang chủ</option>
<option value="?thamso=tin_tuc" <?php echo $a_3; ?> >Tin tức</option>
<option value="?thamso=san_pham_moi" <?php echo $a_4; ?> >Sản phẩm mới</option>
<option value="?thamso=lien_he" <?php echo $a_5; ?> >Liên hệ</option>
</select><br>
<?php
if($link_hd=="?thamso=xuat_mot_tin&id=108")
{
$an_hien="display:block;";
}
else
{
$an_hien="display:none;";
}
?>
<div id="id_bai_viet" style="<?php echo $an_hien; ?>" >Id bài viết : <select onchange="h_k12(this.value)" name="id_bai_viet" id="sl_o2">
<option value="108" >Chưa chọn</option>
<?php
for($i=1;$i<=100;$i++)
{
echo "<option value=’$i’ >";
echo $i;
echo "</option>";
}
?>
</select>
<div id="text_r9" style="line-height:30px">
<h6><span style="font-size: 14pt;">Hãy chọn 1 id để liên kết tới bài viết muốn sữa</span></h6>
</div>
</div>
<input name="link" size="50" id="link" value="<?php echo $link_hd; ?>" type="hidden" />
<?php

?>
</td>
</tr>

<tr>
<td><b>Url đẹp : </b></td>
<td><input type="text" name="url_dep" size="50" value="" /></td>
</tr>

<!–<tr>
<td><b>Tiêu Đề : <br>(English)</b></td>
<td valign="top"><input type="text" name="txttd_en" size="50"/></td>
</tr>–>
<tr>
<td colspan="2">
<input type="hidden" name="form_hd_555" value="form_hd_555" />
<input type="submit" class="nut_chapnhan" value="Thêm Menu" />
</td>
</tr>
</table>
</form>
<?php
//khoangtrang_p(10);
?>
<script type="text/javascript">
table_css_2("er");
</script>
<pre>[/sourcecode]

Các bạn chịu khó nhé bài này hơi dài 1 chút mình sẽ cắt ngắn vào bài sau
Chúc các bạn học tốt




    Khóa Học :
    Thời Gian Học : sángchiềutối

    Bình luận

    order

    Nguyễn Thị Thúy số điện thoại: 082.342.xxx
    tại c4/42 đường võ văn vân, ấp 3, xã vĩnh lộc b, huyện bình chánh vừa đăng ký tư vấn khóa học 8 phút trước

    order

    Nguyễn Thị Thúy số điện thoại: 082.342.xxx
    tại c4/42 đường võ văn vân, ấp 3, xã vĩnh lộc b, huyện bình chánh vừa đăng ký tư vấn khóa học 8 phút trước