Tải bản đầy đủ (.pdf) (40 trang)

Luận văn xây dựng wesite bán giày dép

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (3.49 MB, 40 trang )

 

 

BỘ CÔNG THƢƠNG
TRƢỜNG CAO ĐẲNG CÔNG THƢƠNG



BÁO CÁO ĐỒ ÁN MÔN HỌC PHP


Đề tài:

THIẾT KẾ WEBSITE
XÂY DƢNG WESITE BÁN GIÀY DÉP




GVDH: Hồ Diên Lợi
SVTH: 1.
Lớp: CĐ Tin 32A
Khoá: 2008-2011Tp.HCM, năm 201112007
 
NHẬN XÉT CỦA GIÁO VIÊN












































 
LỜI NÓI ĐẦU
______
0
0
0
______



 



 


 



thôn máy tính của bạn.






Website Bán Giày Dép




.
 



 n
 .





 
WEBSITE:
SHOP BÁN GIÀY DÉP

:SITE
SHOP BÁN GIÀY DÉP
I.1Cơ sở dữ liệu:gồm 8 bảng:

(id,tensanphamm,giasanpham,noisanxuat,tomtat,noidung,hinhanh,trangthai,danhm
uc,id,masp,ghichu,ngay,deleted)



(id,tieude,tomtat,noidung,hinhanh,trangthai,danhmuc_tintuc,matintuc,ngaydang,ghichu,delete
d)
_
5:Menu(id,key ,name,parent,page)
6:Login(id ,username,pass,uname,email,phone,address,utype,active,uskey)
7:(id,tm,ip)
hang(id,hoten,diachi,dienthoai,content,ngay,ghichu)
I.2 Nội dung code để xây dƣng trang web
1:File Function.php:Chức năng :xây dựng các hàm trong bài

Dòng lệnh kêt nối data:tên data là ngochiep
<?php

class database
{
private $_host = "localhost";
private $_user = "root";
private $_pwd = "";
private $_db = "vthiep_db";
private $_status = true;
private $_conn = null;

function __construct($in_host, $in_user, $in_pwd, $in_db, $get_default){
if($get_default == true){
$this->_host = $in_host;
$this->_user = $in_user;
$this->_pwd = $in_pwd;
$this->_db = $in_db;

}
}
 

function connect(){
$this->_conn = mysql_connect($this->_host, $this->_user, $this->_pwd);
if(!$this->_conn){
echo "Connection string incorrect";
$this->_status = false;
}else{
$db_selected = mysql_select_db($this->_db);
mysql_query("set names 'utf8'");
if(!$db_selected){
echo "Could not connect ".$this->_db;
$this->_status = false;
}
}
Hàm ( public function get_products())


 (function get_news_list($in_pk))

 
function get_user_login($in_user, $in_pwd)
{
if($this->_status)
{
$user = $in_user;
$pwd = md5($in_pwd);
$q_user = "select username, pass, uname, utype, user_key from login

where username = '$user' and pass = '$pwd' and active='1'";
$r_user = mysql_query($q_user);
$user_rows = mysql_num_rows($r_user);
if($user_rows == 1)
{
$rsUser = mysql_fetch_array($r_user);
$_SESSION["user_login"] = $rsUser[0];
$_SESSION["name_login"] = $rsUser[2];
$_SESSION["type_login"] = $rsUser[3];
$_SESSION["key_login"] = $rsUser[4];
header("Location: admin/index.php");
ob_end_flush();
}else{
echo "Login failed!";
}
Hàm lất tất cả các dòng trong cở sở dữ liệu : phpmyadmin
function mysql_fetch_all($result) {
while($row = mysql_fetch_array($result)) {
 
$return[] = $row;
}
return $return;
2:FILE DATA_SITE.PHP
require_once("admin/data.php"); gọi tới hàm admin/data.php hay kết nối tới hàm
admin/data.php
admin/data
2.1: Hàmpublic function get_product_index
a danh

  


2.2:Hàm public function product_detail($in_pk)

where là chon masp 
2.3:Hàm   function
get_product_list($in_pk)
 $in_pk
 
function get_news_list()

Select   

public function news_detail($in_pk){

 


 
public function get_other($in_page){


$title = "Infomation";
if(array_key_exists($in_page, $title_page)){
$title = $title_page[$in_page];
}
echo "<div class=\"title_sp\">".$title."</div>";
echo "<div class=\"rdata\">";
require_once($in_page.".php");
echo "</div>";
}

2.7: function finished_cart() 
tháng 
 



2.8: function login :Hàm Login



public function login(){
$user = $_POST["user_name"];
$pwd = $_POST["pwd"];
$this->get_user_login($user, $pwd);
}

function get_user_login($in_user, $in_pwd)
{
$user = $in_user;
$pwd = md5($in_pwd);
$q_user = "select username, pass, uname, utype, user_key from login
where username = '$user' and pass = '$pwd' and active='1'";
$r_user = mysql_query($q_user);
$user_rows = mysql_num_rows($r_user);
if($user_rows == 1)
{
$rsUser = mysql_fetch_array($r_user);
$_SESSION["user_login"] = $rsUser[0];
$_SESSION["name_login"] = $rsUser[2];
$_SESSION["type_login"] = $rsUser[3];

$_SESSION["key_login"] = $rsUser[4];
header("Location: admin/index.php");
ob_end_flush();
}else{
echo "Login failed!";
}
}
function mysql_fetch_all($result)
{
while($row = mysql_fetch_array($result))
{
$return[] = $row;
}
return $return;
}

require_once("function.php");base
require_once("function.php");
 
class menu
{
function get_menu()
{
//$db = new database("localhost", "hiep", "vthiep", "vuthihiep", true);
$db = new database("localhost", "vthiep", "vthpwd", "vthiep_db",
false);
$db->connect();
$q_menu = "select * from menu where parent = '0'";
$r_menu = mysql_query($q_menu);
$menu = $db->mysql_fetch_all($r_menu);


for($i=0; $i< count($menu); $i++){
echo "<div id=\"p_{$menu[$i][1]}\" class=\"iNavBar\"
onmouseover=\"show_div(this)\" onmouseout=\"hide_div(this)\">";
echo "<a href='{$menu[$i][4]}'>{$menu[$i][2]}</a>";

$q_subm = "select * from menu where parent =
'{$menu[$i][1]}'";
$r_subm = mysql_query($q_subm);
if(mysql_num_rows($r_subm)>0){
$subm = $db->mysql_fetch_all($r_subm);
if(count($subm)>0)
{
echo "<div id=\"sub_{$menu[$i][1]}\"
class=\"submenu\" style=\"display:none\">";
for($s = 0; $s < count($subm); $s++){
echo "<li style=\"padding: 5px 20px; list-
style-type:none\">
<! <a
href='?page=plist&pk={$subm[$s][1]}'>".$subm[$s][2]."</a> >
<a
href='{$subm[$s][4]}{$subm[$s][1]}'>".$subm[$s][2]."</a>
</li>";
}
echo "</div>";
}
}
echo "</div>";
}
}

}
?>
 $q_menu = "select * from menu
where parent = '0'";
 
$r_menu = mysql_query($q_menu);
$menu = $db->mysql_fetch_all($r_menu);
 
menu
4:File index

<div id="wrapper">


<div id="navbar">
<?php
require_once("navbar.php");->
$mn = new menu();
$mn->get_menu();
?>

<div id="bodyp"> 
<div id="bp-top"> 
<div id="img_slide"> 
<div id="lastest_new"> 
< require_once("lastest_new.php"); 
<div id="bp-content"> 
<div id="content-left"> 
<div id="menu-right"> 
<?php

require_once("sanpham.php");
$p = new getData();
$page = "";
$pk = "";
pk
if($page == "pd"){
$p->product_detail($pk);
}
else if($page == "pl"){
$p->product_list($pk);
}


else if($page == "nl"){
$p->news_list($pk);
}
else if($page == "nd"){
$p->news_detail($pk);
 
}


else if( $page == "login"){
$f = $p->login();

}
else if( $page == "logout"){
session_destroy();
header("location: ./");
}


<div id="menu-right"> 
require_once("giohang.php"); àng.php trong file index
require_once("quangcao.php");
<div id="foot"> 
5  :


 
$_SESSION  
là 1 dùng hàm count  
$_SESSION
6 :File Style
 : trong các file .php
I.3 :Trang Admintractor
1:File Data.php :Ý nghia file:

2:File Lib.php:Ý 

include(" /ckeditor/ckeditor.php") 
3.File Content.php :
require_once("lib.php");
require_once("data.php");  


là page=mu
4:File Menu.php:
lý ti
5:File Index.php: 
6:File style .php :

 
7:File page.php: file: require_once("menu.php");
require_once("menu.php"); 

8:File Data:
mp: là , trong mp có del.php,edit.php,có ins.php,view.php.Del là xóa 


mn: là 
  


mu: là 
  ng




9:File login.php:Giúp 

Pass:123





:  

TRÌNH PHP



2.1:Giới thiệu:




Client


Server


 
Database

2.2.MỘT SỐ CÂU LỆNH THAO TÁC VỚI CSDL:



Delete


2.3.Tạo CSDL:

:Giao diện đồ hoạ - trực tiếp:


B2:Trong màn hình giao d

 






:Dùng câu lệnh Create database:
se thông



2.4:Kết nối CSDL:
:Tạo kết nối:
Cú pháp: mysql_connect(servername,username,password);





:Chọn CSDL:


 

 
Cú pháp:
Mysql_select_db(database, connection);



Truy vấn CSDL:




Cú pháp:
Mysql_query(query, connection);



Một số hàm truy vấn CSDL MYSQL thông dụng:



mysql_cre
mysql_drop_db():xoá CSDL




 




2.5: Một số hàm thông dụng trong php
2.6 Mã PHP trong HTML:

<?php

?>
 hello world


2.7 Thẻ PHP:


<?php

 
?>

2.8 Khoảng trắng trong PHP:


2.9 Ghi chú:




2.10 Gọi hàm:



2.11 Truy cập biến Form:



2.12 Biến form:



2.13Ghép nối chuỗi:



2.14 Gán giá trị cho biến :


2.15 các kiểu dữ liệu trong PHP :





--




Ví d

 



2.16 Định nghĩa hằng:




de

chúng:


2.17 Toán tử trong PHP:
-,*,/,%

2.18 Phát biểu có điều khiển:
2.19 Các câu lệnh rẽ nhánh:







{

}


{

}











 




{

echo
}






{

}
else
{

}




{
 }
else

{

}


khoá elseif:

{
1;
}

{

}
 


{

}

2.20 Lệnh điều khiển vòng lặp:






a) vòng lặp while:



 
{

}










<?php
$i=0;
$tong=0;
while($i<=5)
{
$tong=$tong+$i;
$i+=1;
}
?>

b) Vòng lặp do…while:
 






do
{



<?php
$i=0;
$tong=0;
do
{
$tong=$tong+$i;
$i+=1;
} while($i<=5);
?>

c) Vòng lặp for:


for( $bien=gia_tri_dau;$bien< ||<= gia_tri_ket_thuc;tang_bien_dem) {
//khoi lenh
}

for($i=1;$i<10;$i++)
{
echo("gia tri cua bien $i la:".$i);
}

while:

for(bieu_thuc_1;bieu_thuc_2;bieu_thuc_3)
{//khoi lenh}
endfor;

<?php
for($i=1;$i<=10;i++)
?>
<tr><td><input type="text"></td></tr>
<?php
 
endfor
?>













III:
III 
 

 





III.2 :Trang Giày Dép Châu Á
 

 

III.3 :Giày Dép Châu Âu

×