php购物车实现代码(1/2)

 更新时间:2016年11月25日 16:27  点击:1483
关于购物车,这个是在电子商务方面使用的比较多,用户选择好自己的商品需要保存起来,最后去收银台,这很像我们实际生活的超市,所以我现来写一个简单的php购物车实例代码,比较详细只要一步步,处理好就OK了。

些购物车会用到php文件
 main.php 显示商品
 additem.php把商品加入购物车
 cearcart.php删除购物车中的商品
 shoppingcart.php 操作类
 
用户的数据库教程有

 代码如下 复制代码
 inventory
  create table inventory (
    product tinytext not null,
    quantity tinytext not null,
    id int(4) default '0' not null auto_increment,
    description tinytext not null,
    price float(10,2) default '0.00' not null,
    category char(1) default '' not null,
    key id (id),
    primary key (id),
    key price (price)
  );
  insert into inventory values ('硬盘','5','1','80g','5600','1');
  insert into inventory values ('cpu','12','2','p4-2.4g','6600','1');
  insert into inventory values ('dvd-rom','7','3','12x','2000','1');
  insert into inventory values ('主板www.111cn.net','3','4','asus','5000','2');
  insert into inventory values ('显示卡','6','5','64m','4500','1');
  insert into inventory values ('刻录机','4','6','52w','3000','1');
 
 shopping
  create table shopping (
    session tinytext not null,
    product tinytext not null,
    quantity tinytext not null,
    card tinytext not null,
    id int(4) default '0' not null auto_increment,
    key id (id),
    primary key (id)
  );
 shopper
 
  create database shopper;
  use shopper;
  create table shopping (
    session tinytext not null,
    product tinytext not null,
    quantity tinytext not null,
    card tinytext not null,
    id int(4) default '0' not null auto_increment,
    key id (id),
    primary key (id)
  );
  create table inventory (
    product tinytext not null,
    quantity tinytext not null,
    id int(4) default '0' not null auto_increment,
    description tinytext not null,
    price float(10,2) default '0.00' not null,
    category char(1) default '' not null,
    key id (id),
    primary key (id),
    key price (price)
  );
  insert into inventory values ('硬盘','5','1','80g','5600','1');
  insert into inventory values ('cpu','12','2','p4-2.4g','6600','1');
  insert into inventory values ('dvd-rom','7','3','12x','2000','1');
  insert into inventory values ('主板111cn.net','3','4','asus','5000','2');
  insert into inventory values ('显示卡','6','5','64m','4500','1');
  insert into inventory values ('刻录机','4','6','52w','3000','1');

*/

//main.php 显示购物车所有商品

 代码如下 复制代码

include("shoppingcart.php");
$cart = new cart;
$table="shopping";

/* 查询并显示所有存货表中的信息 */
    $query = "select * from inventory";
    $invresult = mysql教程_query($query);
    if (!($invresult)) {
       echo "查询失败<br>";
       exit;
    }
    echo "以下产品可供订购∶";
    echo "<table border=0>";
    echo "<tr><td bgcolor=#aaccff>产品编号</td><td bgcolor=#aaccff>产品名称</td><td bgcolor=#aaccff>单价</td>";
    echo "<td bgcolor=#aaccff>剩余数量</td><td bgcolor=#aaccff>产品描述</td><td bgcolor=#aaccff>放入购物车</td></tr>";
    while($row_inventory = mysql_fetch_object($invresult)) {
    echo "<tr><td bgcolor=#aaccff>".$row_inventory->id."</td>";
    echo "<td bgcolor=#aaccff>".$row_inventory->product."</td>";
    echo "<td bgcolor=#aaccff>".$row_inventory->price."</td>";
    echo "<td bgcolor=#aaccff>".$row_inventory->quantity."</td>";
    echo "<td bgcolor=#aaccff>".$row_inventory->description."</td>";
    echo "<td bgcolor=#aaccff><a href='additem.php?product=".$row_inventory->product."'><img border='0' src='cart.gif' width='81' height='17'></a></td></tr>";
    }
    echo "</table>";
    echo "<br>购物车中产品的数量∶".$cart->quant_items($table, $session);
    echo "<br><br><a href='clearcart.php'><img border='0' src='car.gif'></a>清空购物车";

 

直接用php创建word文档代码(系统无需安装word软件) 使用方法: 首先用$word->start()表示要生成word文件了。 然后你可以输出任何的HTML代码,不论是从文件读过来再写到这里, 还是直接在这里输出HTML,都没有关系。

等你输出完毕后,用$word->save($path)方法,其中$path是你想 生成的word文件的名称(可以给出完整的路径).当你使用了$word->save() 方法后,这后面的任何输出都和word文件没有关系了,也就是说word的生成 工作就完成了。之后就和你平常使用php的方式一样拉。随便你输出什么东西, 都直接在浏览器里输出,而不会写到word里面去。

*/

 代码如下 复制代码

class word

function start()
{
ob_start();
print'<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/tr/rec-html40">';

}

function save($path)
{

print "</html>";
$data = ob_get_contents();

ob_end_clean();

$this->wirtefile ($path,$data);
}

function wirtefile ($fn,$data)
{

$fp=fopen($fn,"wb");
fwrite($fp,$data);
fclose($fp);
}

}
//生成word调用方法
include("word.php");
$word=new word;
$word->start();

这个文件上传类可以实现多个文件或单个文件进行上传了,下面小编来给各位推荐一个不错的例子。

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<?php
//php文件上传类(该类支持单个或者多个文件上传)
 /**
 * 类名:upfile
 * 作用:处理文件上传
 * 说明,该类处理单个或者多个文件上传,使用该类时,只需要实列化该类
 * 例:
 * $up = upfile()
 * $up->update_file($_file['filename'])
 *
 * $up->update_file   函数返回一个数组,如果是多文件上传,则为多维数据。
 * 数组的内容:
 * $fileinfo['file_size']   上传文件的大小
 * $fileinfo['file_suffix'] 上传文件的类型
 * $fileinfo['file_name']   上传文件的名字
 * $fileinfo['error']     上传文件产生的错误
 *

 */
class upfile {
 public $fcount = 1;           //上传文件的数量
 public $ftype  = array('jpg','jpeg','gif','png');  //文件格式
 public $fsize  = 1024;          //文件大小单位kb
 public $fdir   = 'www.111cn.net/';         //文件存放目录
 public $errormsg = '';          //产生的临时错误信息

 /**
  *函数名:get_tmp_file($putfile)
  *作用:取得上传的临时文件名
  *@param array $putfile
  *@return string $upimg 返回临时文件名
  */
  function get_tmp_file($putfile){
  if($this->fcount == 1){
   $tmpfile = $putfile['tmp_name'];
  }else{
   for($i=0;$i<$this->fcount;$i++){
    $tmpfile[] = $putfile['tmp_name'][$i];
   }
  }
  return $tmpfile;
  }

在php文件上传这一款,如果不用ajax来实现,效果都不怎么样,用户体验不怎么好,下面我们就来看看这一款ajax+php 无刷新文件上传代码吧。ajax+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.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>ajax+php 无刷新文件上传代码</title>
</head>
<body>
<style>
.fu_list {
 width:600px;
 background:#ebebeb;
 font-size:12px;
}
.fu_list td {
 padding:5px;
 line-height:20px;
 background-color:#fff;
}
.fu_list table {
 width:100%;
 border:1px solid #ebebeb;
}
.fu_list thead td {
 background-color:#f4f4f4;
}
.fu_list b {
 font-size:14px;
}
/*file容器样式*/
a.files {
 width:90px;
 height:30px;
 overflow:hidden;
 display:block;
 border:1px solid #bebebe;
 background:url(img/fu_btn.gif) left top no-repeat;
 text-decoration:none;
}
a.files:hover {
 background-color:#ffffee;
 background-position:0 -30px;
}
/*file设为透明,并覆盖整个触发面*/
a.files input {
 margin-left:-350px;
 font-size:30px;
 cursor:pointer;
 filter:alpha(opacity=0);
 opacity:0;
}
/*取消点击时的虚线框*/
a.files, a.files input {
 outline:none;/*ff*/
 hide-focus:expression(this.hidefocus=true);/*ie*/
}
</style>
<form id="uploadform" action="file.php">
  <table border="0" cellspacing="1" class="fu_list">
    <thead>
      <tr>
        <td colspan="2"><b>上传文件</b></td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="right" width="15%" style="line-height:35px;">添加文件:</td>
        <td><a href="网页特效:void(0);" class="files" id="idfile"></a> <img id="idprocess" style="display:none;" src="img/loading.gif" /></td>
      </tr>
      <tr>
        <td colspan="2"><table border="0" cellspacing="0">
            <thead>
              <tr>
                <td>文件路径</td>
                <td width="100"></td>
              </tr>
            </thead>
            <tbody id="idfilelist">
            </tbody>
          </table></td>
      </tr>
      <tr>
        <td colspan="2" style="color:gray">温馨提示:最多可同时上传 <b id="idlimit"></b> 个文件,只允许上传 <b id="idext"></b> 文件。 </td>
      </tr>
      <tr>
        <td colspan="2" align="center" id="idmsg"><input type="button" value="开始上传" id="idbtnupload" disabled="disabled" />
          &nbsp;&nbsp;&nbsp;
          <input type="button" value="全部取消" id="idbtndel" disabled="disabled" />
        </td>
      </tr>
    </tbody>
  </table>
</form>
<script type="text/网页特效">

var isie = (document.all) ? true : false;

var $ = function (id) {
    return "string" == typeof id ? document.getelementbyid(id) : id;
};

var class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}

var extend = function(destination, source) {
 for (var property in source) {
  destination[property] = source[property];
 }
}

var bind = function(object, fun) {
 return function() {
  return fun.apply(object, arguments);
 }
}

var each = function(list, fun){
 for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); }
};

//文件上传类
var fileupload = class.create();
fileupload.prototype = {
  //表单对象,文件控件存放空间
  initialize: function(form, folder, options) {
 
 this.form = $(form);//表单
 this.folder = $(folder);//文件控件存放空间
 this.files = [];//文件集合
 
 this.setoptions(options);
 
 this.filename = this.options.filename;
 this._framename = this.options.framename;
 this.limit = this.options.limit;
 this.distinct = !!this.options.distinct;
 this.extin = this.options.extin;
 this.extout = this.options.extout;
 
 this.oninifile = this.options.oninifile;
 this.onempty = this.options.onempty;
 this.onnotextin = this.options.onnotextin;
 this.onextout = this.options.onextout;
 this.onlimite = this.options.onlimite;
 this.onsame = this.options.onsame;
 this.onfail = this.options.onfail;
 this.onini = this.options.onini;
 
 if(!this._framename){
  //为每个实例创建不同的iframe
  this._framename = "uploadframe_" + math.floor(math.random() * 1000);
  //ie不能修改iframe的name
  var oframe = isie ? document.createelement("<iframe name="" + this._framename + "">") : document.createelement("iframe");
  //为ff设置name
  oframe.name = this._framename;
  oframe.style.display = "none";
  //在ie文档未加载完用appendchild会报错
  document.body.insertbefore(oframe, document.body.childnodes[0]);
 }
 
 //设置form属性,关键是target要指向iframe
 this.form.target = this._framename;
 this.form.method = "post";
 //注意ie的form没有enctype属性,要用encoding
 this.form.encoding = "multipart/form-data";

 //整理一次
 this.ini();
  },
  //设置默认属性
  setoptions: function(options) {
    this.options = {//默认值
  filename: "files[]",//文件上传控件的name,配合后台使用
  framename: "",//iframe的name,要自定义iframe的话这里设置name
  oninifile: function(){},//整理文件时执行(其中参数是file对象)
  onempty: function(){},//文件空值时执行
  limit:  10,//文件数限制,0为不限制
  onlimite: function(){},//超过文件数限制时执行
  distinct: true,//是否不允许相同文件
  onsame:  function(){},//有相同文件时执行
  extin:  ["gif","jpg","rar","zip","iso","swf","exe"],//允许后缀名
  onnotextin: function(){},//不是允许后缀名时执行
  extout:  [],//禁止后缀名,当设置了extin则extout无效
  onextout: function(){},//是禁止后缀名时执行
  onfail:  function(){},//文件不通过检测时执行(其中参数是file对象)
  onini:  function(){}//重置时执行
    };
    extend(this.options, options || {});
  },
  //整理空间
  ini: function() {
 //整理文件集合
 this.files = [];
 //整理文件空间,把有值的file放入文件集合
 each(this.folder.getelementsbytagname("input"), bind(this, function(o){
  if(o.type == "file"){ o.value && this.files.push(o); this.oninifile(o); }
 }))
 //插入一个新的file
 var file = document.createelement("input");
 file.name = this.filename; file.type = "file"; file.onchange = bind(this, function(){ this.check(file); this.ini(); });
 this.folder.appendchild(file);
 //执行附加程序
 this.onini();
  },
  //检测file对象
  check: function(file) {
 //检测变量
 var bcheck = true;
 //空值、文件数限制、后缀名、相同文件检测
 if(!file.value){
  bcheck = false; this.onempty();
 } else if(this.limit && this.files.length >= this.limit){
  bcheck = false; this.onlimite();
 } else if(!!this.extin.length && !regexp(".(" + this.extin.join("|") + ")$", "i").test(file.value)){
  //检测是否允许后缀名
  bcheck = false; this.onnotextin();
 } else if(!!this.extout.length && regexp(".(" + this.extout.join("|") + ")$", "i").test(file.value)) {
  //检测是否禁止后缀名
  bcheck = false; this.onextout();
 } else if(!!this.distinct) {
  each(this.files, function(o){ if(o.value == file.value){ bcheck = false; } })
  if(!bcheck){ this.onsame(); }
 }
 //没有通过检测
 !bcheck && this.onfail(file);
  },
  //删除指定file
  delete: function(file) {
 //移除指定file
 this.folder.removechild(file); this.ini();
  },
  //删除全部file
  clear: function() {
 //清空文件空间
 each(this.files, bind(this, function(o){ this.folder.removechild(o); })); this.ini();
  }
}

var fu = new fileupload("uploadform", "idfile", { extin: ["gif","jpg"],
 oninifile: function(file){ file.value ? file.style.display = "none" : this.folder.removechild(file); },
 onempty: function(){ alert("请选择一个文件"); },
 onlimite: function(){ alert("超过上传限制"); },
 onsame: function(){ alert("已经有相同文件"); },
 onnotextin: function(){ alert("只允许上传" + this.extin.join(",") + "文件"); },
 onfail: function(file){ this.folder.removechild(file); },
 onini: function(){
  //显示文件列表
  var arrrows = [];
  if(this.files.length){
   var othis = this;
   each(this.files, function(o){
    var a = document.createelement("a"); a.innerhtml = "取消"; a.href = "javascript:void(0);";
    a.onclick = function(){ othis.delete(o); return false; };
    arrrows.push([o.value, a]);
   });
  } else { arrrows.push(["<font color='gray'>没有添加文件</font>", "&nbsp;"]); }
  addlist(arrrows);
  //设置按钮
  $("idbtnupload").disabled = $("idbtndel").disabled = this.files.length <= 0;
 }
});

$("idbtnupload").onclick = function(){
 //显示文件列表
 var arrrows = [];
 each(fu.files, function(o){ arrrows.push([o.value, "&nbsp;"]); });
 addlist(arrrows);
 
 fu.folder.style.display = "none";
 $("idprocess").style.display = "";
 $("idmsg").innerhtml = "正在添加文件到您的网盘中,请稍候……<br />有可能因为网络问题,出现程序长时间无响应,请点击"<a href='?'><font color='red'>取消</font></a>"重新上传文件";
 
 fu.form.submit();
}

//用来添加文件列表的函数
function addlist(rows){
 //根据数组来添加列表
 var filelist = $("idfilelist"), ofragment = document.createdocumentfragment();
 //用文档碎片保存列表
 each(rows, function(cells){
  var row = document.createelement("tr");
  each(cells, function(o){
   var cell = document.createelement("td");
   if(typeof o == "string"){ cell.innerhtml = o; }else{ cell.appendchild(o); }
   row.appendchild(cell);
  });
  ofragment.appendchild(row);
 })
 //ie的table不支持innerhtml所以这样清空table
 while(filelist.haschildnodes()){ filelist.removechild(filelist.firstchild); }
 filelist.appendchild(ofragment);
}


$("idlimit").innerhtml = fu.limit;

$("idext").innerhtml = fu.extin.join(",");

$("idbtndel").onclick = function(){ fu.clear(); }

//在后台通过window.parent来访问主页面的函数
function finish(msg){ alert(msg); location.href = location.href; }

</script>
</body>
</html>

file.php文件

<?
$sort=12;
$f_type=strtolower("swf,jpg,rar,zip,7z,iso,gif");//设置可上传的文件类型
$file_size_max=200*1024*1024;//限制单个文件上传最大容量
$overwrite = 0;//是否允许覆盖相同文件,1:允许,0:不允许
$f_input="files";//设置上传域名称
    foreach($_files[$f_input]["error"] as $key => $error){
        $up_error="no";
        if ($error == upload_err_ok){
            $f_name=$_files[$f_input]['name'][$key];//获取上传源文件名
   $uploaddir ='./www.111cn.net/';
            $uploadfile=$uploaddir.strtolower(basename($f_name));
            
            $tmp_type=substr(strrchr($f_name,"."),1);//获取文件扩展名
   $tmp_type=strtolower($tmp_type);
            if(!stristr($f_type,$tmp_type)){
                echo "<script>alert('对不起,不能上传".$tmp_type."格式文件, ".$f_name." 文件上传失败!')</script>";
                $up_error="yes";
            }
            
            if ($_files[$f_input]['size'][$key]>$file_size_max) {
   
                echo "<script>alert('对不起,你上传的文件 ".$f_name." 容量为".round($_files[$f_input]
['size'][$key]/1024)."kb,大于规定的".($file_size_max/1024)."kb,上传失败!')</script>";
                $up_error="yes";
            }
            
            if (file_exists($uploadfile)&&!$overwrite){
                echo "<script>alert('对不起,文件 ".$f_name." 已经存在,上传失败!')</script>";
                $up_error="yes";
            }
             $string = 'abcdefghijklmnopgrstuvwxyz0123456789';
$rand = '';
for ($x=0;$x<12;$x++)
  $rand .= substr($string,mt_rand(0,strlen($string)-1),1);
$t=date("ymdhis").substr($gettime[0],2,6).$rand;
$attdir="./file/"; 
    if(!is_dir($attdir))  
    {  mkdir($attdir);}
            $uploadfile=$attdir.$t.".".$tmp_type;
            if(($up_error!="yes") and (move_uploaded_file($_files[$f_input]['tmp_name']

[$key], $uploadfile))){

                
    $_msg=$_msg.$f_name.'上传成功 ';
    
    
            }
   else{
   $_msg=$_msg.$f_name.'上传失败 ';
   }
        }
 
    }
echo "<script>window.parent.finish('".$_msg."');</script>"; 
?>

 代码如下 复制代码
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title></title>
<script language="网页特效" type="text/网页特效">
function addinput()//增加input节点
{
var input=document.createelement('input');//创建一个input节点
var br=document.createelement('br');//创建一个br节点
input.setattribute('type','file');// 设置input节点type属性为file
input.setattribute('name','files[]');//设置input节点 name属性为files[],以 数组的方式传递给服务器端
document.form1.appendchild(br);//把节点添加到 form1表单中
document.form1.appendchild(input);
}
</script>
</head>
<?php
if($_post['sub']=="www")
{
$waterimg="water.png";
$ftype=array('image/jpg','image/jpeg','imgage/png','image/pjpeg','image/gif');//允许上传的文件类型
$files=$_files['files'];
$fnum=count($files['name']); //取得上传文件个数
for($i=0;$i<$fnum;$i++)
{
 
   if($files['name'][$i]!=''&&is_uploaded_file($files['tmp_name'][$i]))
   {
  
    if(in_array($files['type'][$i],$ftype))//判断文件是否是允许的类型
    {
 
     $fname[$i]='upfile/'.rand(0,10000).time().substr($files['name'] [$i],strrpos($files['name'][$i],'.'));//自动命名
     move_uploaded_file($files['tmp_name'][$i],$fname[$i]);
     echo '<br/>文件上传成功!';
 
    }
    else
    {
     echo '<br/>不允许的文件类型!';
  exit;
    }
   }
   else
   {
    echo '<br/>该文件不存在!';
 exit;
   }
watermark($fname[$i],$waterimg);   
}
 
  $string=implode('|',$fname);
 echo $string;
}
 
?>
<body>
<form name="form1" method="post" action="" enctype="multipart/form-data" >
    <input type="file" name="files[]" id="files[]" />
<input type="submit" name="sub" value="上传"/>
<input name="sub" type="hidden" id="sub" value="www" />
</form>
<a href="#" onclick="addinput()">再上传一张</a>
<?
/**
* 为图片加水印
* @param string $desimg 目标图片 参数格式为 ./images/pic.jpg
* @param string $waterimg 水印图片 参数格式同上,水印图片为 png格式,背景透明
* @param int positon 水印地位 1:顶部居左 2:顶部居右 3:居中 4 :底部居左 5:底部居右
* @param bool $saveas 能否另存为,默许值false,默示笼盖原图
* @param int $alpha 水印图片的不通明度
* @return string $savepath 新图片的途径
* **/
function watermark($desimg,$waterimg,$positon=1,$saveas=false,$alpha=30)
{
//获取目图片的根基信息
$temp=pathinfo($desimg);
$name=$temp["basename"];//文件名
$path=$temp["dirname"];//文件地点的文件夹
$extension=$temp["extension"];//文件扩展名
if($saveas)
{
//需要另存为
$name=rtrim($name,".$extension")."_2.";//从头命名
$savepath=$path."/".$name.$extension;
}
else
{
//不需要另存为则笼盖原图
$savepath=$path."/".$name;
}
$info=getimageinfo($desimg);//获取目标图片的信息
$info2=getimageinfo($waterimg);//获取水印图片的信息
$desimg=create($desimg);//从原图创立
$waterimg=create($waterimg);//从水印图片创立
//地位1:顶部居左
if($positon==1)
{
$x=0;
$y=0;
}
//地位2:顶部居右
if($positon==2)
{
$x=$info[0]-$info2[0];
$y=0;
}
//地位3:居中
if($positon==3)
{
$x=($info[0]-$info2[0])/2;
$y=($info[1]-$info2[1])/2;
}
//地位4:底部居左
if($positon==4)
{
$x=0;
$y=$info[1]-$info2[1];
}
//地位5:底部居右
if($positon==5)
{
$x=$info[0]-$info2[0];
$y=$info[1]-$info2[1];
}
imagecopymerge($desimg,$waterimg,$x,$y,0,0,$info2[0],$info2[1],$alpha);
imagejpeg($desimg,$savepath);
imagedestroy($desimg);
imagedestroy($waterimg);
return $savepath;
}
/**
* 获取图片的信息,width,height,image/type
* @param string $src 图片途径
* @return 数组
* **/
function getimageinfo($src)
{
return getimagesize($src);
}
/**
* 创立图片,前往本钱范例
* @param string $src 图片途径
* @return resource $im 前往本钱范例
* **/
function create($src)
{
$info=getimageinfo($src);
switch ($info[2])
{
case 1:
$im=imagecreatefromgif($src);
break;
case 2:
$im=imagecreatefromjpeg($src);
break;
case 3:
$im=imagecreatefrompng($src);
break;
}
return $im;
}
 ?>

</body>
</html>

[!--infotagslink--]

相关文章

  • ASP.NET购物车实现过程详解

    这篇文章主要为大家详细介绍了ASP.NET购物车的实现过程,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-09-22
  • php语言实现redis的客户端

    php语言实现redis的客户端与服务端有一些区别了因为前面介绍过服务端了这里我们来介绍客户端吧,希望文章对各位有帮助。 为了更好的了解redis协议,我们用php来实现...2016-11-25
  • jQuery+jRange实现滑动选取数值范围特效

    有时我们在页面上需要选择数值范围,如购物时选取价格区间,购买主机时自主选取CPU,内存大小配置等,使用直观的滑块条直接选取想要的数值大小即可,无需手动输入数值,操作简单又方便。HTML首先载入jQuery库文件以及jRange相关...2015-03-15
  • 不打开网页直接查看网站的源代码

      有一种方法,可以不打开网站而直接查看到这个网站的源代码..   这样可以有效地防止误入恶意网站...   在浏览器地址栏输入:   view-source:http://...2016-09-20
  • php 调用goolge地图代码

    <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
  • JS基于Mootools实现的个性菜单效果代码

    本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
  • JS实现的简洁纵向滑动菜单(滑动门)效果

    本文实例讲述了JS实现的简洁纵向滑动菜单(滑动门)效果。分享给大家供大家参考,具体如下:这是一款纵向布局的CSS+JavaScript滑动门代码,相当简洁的手法来实现,如果对颜色不满意,你可以试着自己修改CSS代码,这个滑动门将每一...2015-10-21
  • JS+CSS实现分类动态选择及移动功能效果代码

    本文实例讲述了JS+CSS实现分类动态选择及移动功能效果代码。分享给大家供大家参考,具体如下:这是一个类似选项卡功能的选择插件,与普通的TAb区别是加入了动画效果,多用于商品类网站,用作商品分类功能,不过其它网站也可以用,...2015-10-21
  • JS实现自定义简单网页软键盘效果代码

    本文实例讲述了JS实现自定义简单网页软键盘效果。分享给大家供大家参考,具体如下:这是一款自定义的简单点的网页软键盘,没有使用任何控件,仅是为了练习JavaScript编写水平,安全性方面没有过多考虑,有顾虑的可以不用,目的是学...2015-11-08
  • php 取除连续空格与换行代码

    php 取除连续空格与换行代码,这些我们都用到str_replace与正则函数 第一种: $content=str_replace("n","",$content); echo $content; 第二种: $content=preg_replac...2016-11-25
  • php简单用户登陆程序代码

    php简单用户登陆程序代码 这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。 <center> <p>&nbsp;</p> <p>&nbsp;</p> <form name="form1...2016-11-25
  • PHP实现清除wordpress里恶意代码

    公司一些wordpress网站由于下载的插件存在恶意代码,导致整个服务器所有网站PHP文件都存在恶意代码,就写了个简单的脚本清除。恶意代码示例...2015-10-23
  • JS实现双击屏幕滚动效果代码

    本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
  • js识别uc浏览器的代码

    其实挺简单的就是if(navigator.userAgent.indexOf('UCBrowser') > -1) {alert("uc浏览器");}else{//不是uc浏览器执行的操作}如果想测试某个浏览器的特征可以通过如下方法获取JS获取浏览器信息 浏览器代码名称:navigator...2015-11-08
  • jQuery+slidereveal实现的面板滑动侧边展出效果

    我们借助一款jQuery插件:slidereveal.js,可以使用它控制面板左右侧滑出与隐藏等效果,项目地址:https://github.com/nnattawat/slideReveal。如何使用首先在页面中加载jquery库文件和slidereveal.js插件。复制代码 代码如...2015-03-15
  • JS日期加减,日期运算代码

    一、日期减去天数等于第二个日期function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(a)alert(a.getFullYear() + "年" + (a.getMonth() +...2015-11-08
  • PHP+jQuery翻板抽奖功能实现

    翻板抽奖的实现流程:前端页面提供6个方块,用数字1-6依次表示6个不同的方块,当抽奖者点击6个方块中的某一块时,方块翻转到背面,显示抽奖中奖信息。看似简单的一个操作过程,却包含着WEB技术的很多知识面,所以本文的读者应该熟...2015-10-21
  • PHP开发微信支付的代码分享

    微信支付,即便交了保证金,你还是处理测试阶段,不能正式发布。必须到你通过程序测试提交订单、发货通知等数据到微信的系统中,才能申请发布。然后,因为在微信中是通过JS方式调用API,必须在微信后台设置支付授权目录,而且要到...2014-05-31
  • SQLMAP结合Meterpreter实现注入渗透返回shell

    sqlmap 是一个自动SQL 射入工具。它是可胜任执行一个广泛的数据库管理系统后端指印, 检索遥远的DBMS 数据库等,下面我们来看一个学习例子。 自己搭建一个PHP+MYSQ...2016-11-25
  • PHP常用的小程序代码段

    本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24