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
5/5 - (2 bình chọn)

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

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

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

Chào các bạn hôm nay mình lại giới thiệu tạo những file đầu tiên trong code

Bước 1 : Tạo file ketnoi.php

[sourcecode language=”plain”]</pre>

<? php mysql_connect ( "localhost", "root", ""); mysql_select_db ( "quanao"); mysql_query ( "SET TÊN" UTF8 " ‘); $ ten_danh_dau__kkk =" ma_so_i79 "; // đường dẫn url cho trang web của $ BASE_URL =" http: // localhost / quanao / "; $ _SESSION [ ‘BASE_URL’] = $ BASE_URL; ?>
<pre>[/sourcecode]

Mình giải thích chút nhé :

mysql_connect(“localhost”,”root”,””); // câu lệnh này dùng để kết nối với xampp với user là root pass là rỗng . Chú ý nếu các bạn đặt khác thì thay đổi cho giống nhé

mysql_select_db(“quanao”);// lựa chọn  CSDL

mysql_query(‘SET NAMES “UTF8″‘); // hiểu tiếng việt trong CSDL

$ten_danh_dau__kkk=”ma_so_i79”;// cái này dùng đánh dấu

$_SESSION[‘base_url’]=$base_url; // lấy đường dẫn chuẩn cho session

tạo 1 forder quanly và web

quanly: dùng để quản lý dữ liệu người dùng để up bài

web : dùng để hiển thị người dùng

Đầu tiên giới thiệu foder quanly :

Bước 1:  tạo 1 file index.php

[sourcecode language=”plain”]</pre>

<?php session_start(); ini_set(‘display_errors’,’0′); include("../ketnoi.php"); include("ham/ham.php"); //echo $_SERVER[‘HTTP_REFERER’]; ?>

<?php include_file("../class/class_luan.php"); include_file("cumchucnang/bien/bien.php"); include_file("class/class.php"); include_file("class/include_class.php"); include("cumchucnang/xacdinh_dangnhap/xacdinh_dangnhap.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Quan ly</title>

<span style="font-size: 14pt;"> <link rel="stylesheet" type="text/css" media="screen" href="giaodien/css/css.css"></span>
<span style="font-size: 14pt;"> <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%20src%3D%22..%2Fgiaodien%2Fchung.js%22%3E%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" /></span>
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%20src%3D%22giaodien%2Ffckeditor%2Ffckeditor.js%22%3E%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%20src%3D%22cumchucnang%2Fajax_submit_form%2Fjs%2Fform-submit.js%22%3E%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%20src%3D%22cumchucnang%2Fajax_submit_form%2Fjs%2Fajax.js%22%3E%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%20src%3D%22..%2Fjquery.min.js%22%3E%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />

<!– menu ngang quan tri –>
<link rel="stylesheet" type="text/css" href="../giaodien/smooth_menu_js/ddsmoothmenu.css" />
<link rel="stylesheet" type="text/css" href="../giaodien/smooth_menu_js/ddsmoothmenu-v.css" />
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%20src%3D%22..%2Fgiaodien%2Fsmooth_menu_js%2Fddsmoothmenu.js%22%3E%0A%0A%2F***********************************************%0A*%20Smooth%20Navigational%20Menu-%20(c)%20Dynamic%20Drive%20DHTML%20code%20library%20(www.dynamicdrive.com)%0A*%20This%20notice%20MUST%20stay%20intact%20for%20legal%20use%0A*%20Visit%20Dynamic%20Drive%20at%20http%3A%2F%2Fwww.dynamicdrive.com%2F%20for%20full%20source%20code%0A***********************************************%2F%0A%0A%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%0A%0Addsmoothmenu.init(%7B%0Amainmenuid%3A%20%22smoothmenu1%22%2C%20%2F%2Fmenu%20DIV%20id%0Aorientation%3A%20’h’%2C%20%2F%2FHorizontal%20or%20vertical%20menu%3A%20Set%20to%20%22h%22%20or%20%22v%22%0Aclassname%3A%20’ddsmoothmenu’%2C%20%2F%2Fclass%20added%20to%20menu’s%20outer%20DIV%0A%2F%2Fcustomtheme%3A%20%5B%22%231c5a80%22%2C%20%22%2318374a%22%5D%2C%0Acontentsource%3A%20%22markup%22%20%2F%2F%22markup%22%20or%20%5B%22container_id%22%2C%20%22path_to_menu_file%22%5D%0A%7D)%0A%0A%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
<h6 style="font-size: 14pt;"><!– menu ngang quan tri –></h6>
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cstyle%3E%0Adiv%23sua_file%7Bz-index%3A100%3B%7D%3Cbr%20%2F%3E%0A%3C%2Fstyle%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;style&gt;" title="&lt;style&gt;" />

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%20src%3D%22jquerymultiplefileupload%2Fjs%2Fajaxupload.3.5.js%22%20%3E%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
<link rel="stylesheet" type="text/css" href="jquerymultiplefileupload/styles.css" />

</head>

<body bgcolor="#ececec">

<?php //include_file("cumchucnang/xuly_form/xuly_form.php"); //include_file("cumchucnang/xuly_bien_get/xuly_bien_get.php"); ?>
<?php if(isset($_POST[‘dangnhap_quantri’])) { include("cumchucnang/dangnhap_quantri/session.php"); //trangtruoc(); chuyentrang("index.php"); exit(); } ?>
<?php if($xacdinh_dangnhap=="co") { include_file("cumchucnang/xuly_form/xuly_form.php"); include_file("cumchucnang/xuly_bien_get/xuly_bien_get.php"); include_file("cumchucnang/quantri/quantri.php"); } else { include_file("cumchucnang/dangnhap_quantri/form_dang_nhap.php"); } ?>
<?php function h_jjj() { ?>
<hr />

<select onchange="window.location=’?thamso=test_include&v=’+this.value" style="padding:20px;margin-left:200px;margin-bottom:30px" ><option value="abc">abc</option><option value="co">co</option><option value="khong">khong</option></select>
<?php if($_GET[‘thamso’]=="test_include") { $up="update thong_so set gia_tri=’$_GET[v]’ where ma_so=’9′ "; mysql_query($up); } } //h_jjj(); ?>
<?php function h_jjj_2() { if(trim($_GET[‘sua_file_php’])=="co") { $noi_dung_file=read_file(trim($_GET[‘file’])); if($_POST[‘sua_file_php’]=="sua_file_php") { write_file($_GET[‘file’],$_POST[‘noi_dung’]); trangtruoc(); exit(); } ?>
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%3E%0Afunction%20dong_sua_file()%0A%7B%0Avar%20id_sua_file%3Ddocument.getElementById(%22sua_file%22)%3B%0A%2F%2Falert(id_sua_file)%3B%0Aid_sua_file.style.display%3D%22none%22%3B%0A%7D%0Afunction%20insertTab(o%2C%20e)%0A%7B%0Avar%20kC%20%3D%20e.keyCode%20%3F%20e.keyCode%20%3A%20e.charCode%20%3F%20e.charCode%20%3A%20e.which%3B%0Aif%20(kC%20%3D%3D%209%20%26%26%20!e.shiftKey%20%26%26%20!e.ctrlKey%20%26%26%20!e.altKey)%0A%7B%0Avar%20oS%20%3D%20o.scrollTop%3B%0Aif%20(o.setSelectionRange)%0A%7B%0Avar%20sS%20%3D%20o.selectionStart%3B%0Avar%20sE%20%3D%20o.selectionEnd%3B%0Ao.value%20%3D%20o.value.substring(0%2C%20sS)%20%2B%20%22%5Ct%22%20%2B%20o.value.substr(sE)%3B%0Ao.setSelectionRange(sS%20%2B%201%2C%20sS%20%2B%201)%3B%0Ao.focus()%3B%0A%7D%0Aelse%20if%20(o.createTextRange)%0A%7B%0Adocument.selection.createRange().text%20%3D%20%22%5Ct%22%3B%0Ae.returnValue%20%3D%20false%3B%0A%7D%0Ao.scrollTop%20%3D%20oS%3B%0Aif%20(e.preventDefault)%0A%7B%0Ae.preventDefault()%3B%0A%7D%0Areturn%20false%3B%0A%7D%0Areturn%20true%3B%0A%7D%0A%0A%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
<div style="width:900px;border:3px solid blue;position:absolute;display:<?php echo $ddd; ?>
;left:50px;top:50px;background:white;z-index:100" id="sua_file">
<h1 tyle="margin-left:25px" >Sữa file</h1>
<form action="" method="post">
<input name="ten_file" size="80" style="margin-left:25px" id="tf_111" value="<?php echo trim($_GET[‘file’]); ?>"/>

<textarea style="width:850px;height:500px;margin-left:25px" name="noi_dung" id="textarea_90" onkeydown="insertTab(this, event);" ><?php echo $noi_dung_file; ?></textarea>

<input type="hidden" name="sua_file_php" value="sua_file_php" />
<input type="submit" value="Sửa" style="margin-left:831px"/>
</form>

<input type="button" value="Đóng" style="margin-left:831px" onclick="dong_sua_file()"/>
</div>

<?php } } //h_jjj_2(); ?>

</body>
</html>
<pre>[/sourcecode]

trong này chúng ta cần 1 số file hiển thị để  kiểm tra hàm , biến  và các file hỗ trợ mình sẽ đi từ trên xuống dưới nhé
Chúc các bạn học php 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