用户注册检测用户名是否存在ajax + php代码

 更新时间:2016年11月25日 15:52  点击:1921
在 用户注册检测用户名是否存在我们要提供告诉用户你要注册的用户名是否可用,那么我们就得利用ajax技术来实例,下面是一款ajax php当用户输入完用户名时提示用户是否可用用的代码

<!--
t.php代码

 代码如下 复制代码

<?
$title = isset($_get['title'])?$_get['title']:'';
if( $title )
{
 $sql ='select id from filecontent where title=''.$title.''';
 $q = mysql教程_query( $sql ) or die( mysql_error());
 if( mysql_num_rows( $q )  )
 {
  echo 1;
 }
 else
 {
  echo 0;
 }
}
else
{
 echo 0;
}
?>

 

<!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>
<script>
//  用户注册检测用户名是否存在ajax + php代码


function createxmlhttprequest(){//创建xmlhttprequest对象
 if(window.activexobject){//ie
  try {
   return new activexobject("microsoft.xmlhttp");
  } catch(e){
   return;
  }
 }else if(window.xmlhttprequest){//mozilla,firefox
  try {
   return new xmlhttprequest();
  } catch(e){
   return;
  }
 }
}

function getrenews(value){//主调函数
 var xmlhttp=createxmlhttprequest();
 var url = "t.php?action=check&title="+value+"&mt="+math.random(300000);
 if (value==""){  
  return false ;
 }
 if (xmlhttp){
  callback = getreadystatehandler(xmlhttp);
  xmlhttp.onreadystatechange = callback;
  xmlhttp.open("get", url,true);
  xmlhttp.send(null);
 }
}
//返回0代表用户名可用,否则提示己被注册。

function getreadystatehandler(xmlhttp){//服务器返回后处理函数
 return function (){
  if(xmlhttp.readystate == 4){
   if(xmlhttp.status == 200){
       
     
     if (xmlhttp.responsetext==1){
       document.getelementbyid("checkid").innerhtml="<font color='red'>对不起,你输入的用户名己被注册!</font>";     
     }else{
      document.getelementbyid("checkid").innerhtml="可以注册";     
     }      
   }
  }
 }
}
</script>
</head>

<body>
给input框增加onblur事件,当用户输入完用户名就检测用户名,并给出提示。
输入用户名<input name="title" type="text" id="title" size="40" onblur="getrenews(this.value);"><span id="checkid"></span>
</body>
</html>

以前我们的购物车都是点击打开网页,都是web 2.0形式的,本文章提供这款php教程 ajax拖动购物车源码,可以拖动商品放在购物车里面,这样更好的适合用户习惯了。
*/
//download by http://www.111cn.net

/* database config */

$db_host  = 'localhost';
$db_user  = 'root';
$db_pass  = 'dcfan2006';
$db_database = 'test';

$link = mysql教程_connect($db_host,$db_user,$db_pass) or die('unable to establish a db connection');
mysql_select_db($db_database,$link);
mysql_query("set names utf8");

?>
<!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>php ajax拖动购物车源码</title>
<script type="text/网页特效" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>

<script>
var purchased=new array();
var totalprice=0;

$(document).ready(function(){
 
 $('.product').simpletip({
  
  offset:[40,0],
  content:'<img src="img/ajax_load.gif" alt="loading" style="margin:10px;" />',
  onshow: function(){
   
   var param = this.getparent().find('img').attr('src');
   
   if($.browser.msie && $.browser.version=='6.0')
   {
    param = this.getparent().find('img').attr('style').match(/src="([^"]+)"/);
    param = param[1];
   }
   
   this.load('ajax/tips教程.php',{img:param});
  }

 });
 
 $(".product img").draggable({
 
 containment: 'document',
 opacity: 0.6,
 revert: 'invalid',
 helper: 'clone',
 zindex: 100
 
 });

 $("div.content.drop-here").droppable({
 
   drop:
     function(e, ui)
     {
      var param = $(ui.draggable).attr('src');
      
      if($.browser.msie && $.browser.version=='6.0')
      {
       param = $(ui.draggable).attr('style').match(/src="([^"]+)"/);
       param = param[1];
      }

      addlist(param);
     }
 
 });

});


function addlist(param)
{
 $.ajax({
 type: "post",
 url: "ajax/addtocart.php",
 data: 'img='+encodeuricomponent(param),
 datatype: 'json',
 beforesend: function(x){$('#ajax-loader').css教程('visibility','visible');},
 success: function(msg){
  
  $('#ajax-loader').css('visibility','hidden');
  if(parseint(msg.status)!=1)
  {
   return false;
  }
  else
  {
   var check=false;
   var cnt = false;
   
   for(var i=0; i<purchased.length;i++)
   {
    if(purchased[i].id==msg.id)
    {
     check=true;
     cnt=purchased[i].cnt;
     
     break;
    }
   }
   
   if(!cnt)
    $('#item-list').append(msg.txt);
    
   if(!check)
   {
    purchased.push({id:msg.id,cnt:1,price:msg.price});
   }
   else
   {
    if(cnt>=3) return false;
    
    purchased[i].cnt++;
    $('#'+msg.id+'_cnt').val(purchased[i].cnt);
   }
   
   totalprice+=msg.price;
   update_total();

  }
  
  $('.tooltip').hide();
 
 }
 });
}

function findpos(id)
{
 for(var i=0; i<purchased.length;i++)
 {
  if(purchased[i].id==id)
   return i;
 }
 
 return false;
}

function remove(id)
{
 var i=findpos(id);

 totalprice-=purchased[i].price*purchased[i].cnt;
 purchased[i].cnt = 0;

 $('#table_'+id).remove();
 update_total();
}

function change(id)
{
 var i=findpos(id);
 
 totalprice+=(parseint($('#'+id+'_cnt').val())-purchased[i].cnt)*purchased[i].price;
 
 purchased[i].cnt=parseint($('#'+id+'_cnt').val());
 update_total();
}

function update_total()
{
 if(totalprice)
 {
  $('#total').html('total: $'+totalprice);
  $('a.button').css('display','block');
 }
 else
 {
  $('#total').html('');
  $('a.button').hide();
 }
}
</script>
<style>
body,h1,h2,h3,p,td,quote,small,form,input,ul,li,ol,label{
 margin:0px;
 padding:0px;
 font-family:arial, helvetica, sans-serif;
}

body{
 color:#555555;
 font-size:13px;
 background-color:#282828;
}

.clear{
 clear:both;
}

#main-container{
 width:700px;
 margin:20px auto;
}

.container{
 margin-bottom:40px;
}

.top-label{
 background:url(img/label_bg.png) no-repeat;
 display:inline-block;
 margin-left:20px;
 position:relative;
 margin-bottom:-15px;
}

.label-txt{
 background:url(img/label_bg.png) no-repeat top right;
 display:inline-block;
 font-size:10px;
 height:36px;
 margin-left:10px;
 padding:12px 15px 0 5px;
 text-transform:uppercase;
}

.content-area{
 background:url(img/container_top.png) no-repeat #fcfcfc;
 padding:15px 20px 0 20px;
}

.content{
 padding:10px;
}

.drag-desired{
 background:url(img/drag_desired_label.png) no-repeat top right;
 padding:30px;
}

.drop-here{
 background:url(img/drop_here_label.png) no-repeat top right;
}


.bottom-container-border{
 background:url(img/container_bottom.png) no-repeat;
 height:14px;
}

.product{
 border:2px solid #f5f5f5;
 float:left;
 margin:15px;
 padding:10px;
}

.product img{
 cursor:move;
}

p.descr{
 padding:5px 0;
}

small{
 display:block;
 margin-top:4px;
}

.tooltip{
 position: absolute;
 top: 0;
 left: 0;
 z-index: 3;
 display: none;

 background-color:#666666;
 border:1px solid #666666;
 color:#fcfcfc;

 padding:10px;
 
 -moz-border-radius:12px;
 -khtml-border-radius: 12px;
 -webkit-border-radius: 12px;
 border-radius:12px;
}

#cart-icon{
 width:128px;
 float:left;
 position:relative;
}

#ajax-loader{
 position:absolute;
 top:0px;
 left:0px;
 visibility:hidden;
}

#item-list{
 float:left;
 width:490px;
 margin-left:20px;
 padding-top:15px;
}

a.remove,a.remove:visited{
 color:red;
 font-size:10px;
 text-transform:uppercase;
}

#total{
 clear:both;
 float:right;
 font-size:10px;
 font-weight:bold;
 padding:10px 12px;
 text-transform:uppercase;
}

#item-list table{
 background-color:#f7f7f7;
 border:1px solid #efefef;
 margin-top:5px;
 padding:4px;
}

a.button,a.button:visited{
 display:none;

 height:29px;
 width:136px;

 padding-top:15px;
 margin:0 auto;
 overflow:hidden;

 color:white; 
 font-size:12px;
 font-weight:bold;
 text-align:center;
 text-transform:uppercase;
 
 background:url(img/button.png) no-repeat center top;
}

a.button:hover{
 background-position:bottom;
 text-decoration:none;
}


a, a:visited {
 color:#00bbff;
 text-decoration:none;
 outline:none;
}

a:hover{
 text-decoration:underline;
}

h1{
 font-size:28px;
 font-weight:bold;
 font-family:"trebuchet ms",arial, helvetica, sans-serif;
}

h2{
 font-weight:normal;
 font-size:20px;
 
 color:#666666;
 text-indent:30px;
 margin:20px 0;
}

.tutorialzine h1{
 color:white;
 margin-bottom:10px;
 font-size:48px;
}

.tutorialzine h3{
 color:#f5f5f5;
 font-size:10px;
 font-weight:bold;
 margin-bottom:30px;
 text-transform:uppercase;
}

.tutorial-info{
 color:white;
 text-align:center;
 padding:10px;
 margin-top:-20px;
}

</style>

<!--[if lt ie 7]>
<style type="text/css">
 .pngfix { behavior: url(pngfix/iepngfix.htc);}
    .tooltip{width:200px;};
</style>
<![endif]-->

</head>

<body>
<div id="main-container">

 <div class="tutorialzine">
    <h1>shopping cart</h1>
    <h3>the best products at the best prices</h3>
    </div>


    <div class="container">
   
     <span class="top-label">
            <span class="label-txt">products</span>
        </span>
       
        <div class="content-area">
   
      <div class="content drag-desired">
             
                <?php

    $result = mysql_query("select * from internet_shop");
    while($row=mysql_fetch_assoc($result))
    {
     echo '<div class="product"><img src="img/products/'.$row['img'].'" alt="'.htmlspecialchars($row['name']).'" width="128" height="128" class="pngfix" /></div>';
    }

    ?>
               
               
                <div class="clear"></div>
            </div>

        </div>
       
        <div class="bottom-container-border">
        </div>

    </div>

 

    <div class="container">
   
     <span class="top-label">
            <span class="label-txt">shopping cart</span>
        </span>
       
        <div class="content-area">
   
      <div class="content drop-here">
             <div id="cart-icon">
              <img src="img/shoppingcart_128x128.png" alt="shopping cart" class="pngfix" width="128" height="128" />
     <img src="img/ajax_load_2.gif" alt="loading.." id="ajax-loader" width="16" height="16" />
                </div>

    <form name="checkoutform" method="post" action="order.php">
               
                <div id="item-list">
                </div>
               
    </form>               
                <div class="clear"></div>

    <div id="total"></div>

                <div class="clear"></div>
               
                <a href="" onclick="document.forms.checkoutform.submit(); return false;" class="button">checkout</a>
               
          </div>

        </div>
       
        <div class="bottom-container-border">
        </div>

    </div>
 
</div>
</body>
</html>

tips.php

<?php

 

if(!$_post['img']) die("there is no such product!");

$img=mysql_real_escape_string(end(explode('/',$_post['img'])));

$row=mysql_fetch_assoc(mysql_query("select * from internet_shop where img='".$img."'"));

if(!$row) die("there is no such product!");

echo '<strong>'.$row['name'].'</strong>

<p class="descr">'.$row['description'].'</p>

<strong>price: $'.$row['price'].'</strong>
<small>drag it to your shopping cart to purchase it</small>';
?>

addtocard.php加入购物车

<?php

define('include_check',1);
require "../connect.php";

if(!$_post['img']) die("there is no such product!");

$img=mysql_real_escape_string(end(explode('/',$_post['img'])));
$row=mysql_fetch_assoc(mysql_query("select * from internet_shop where img='".$img."'"));

echo '{status:1,id:'.$row['id'].',price:'.$row['price'].',txt:'

<table width="100%" id="table_'.$row['id'].'">
  <tr>
    <td width="60%">'.$row['name'].'</td>
    <td width="10%">$'.$row['price'].'</td>
    <td width="15%"><select name="'.$row['id'].'_cnt" id="'.$row['id'].'_cnt" onchange="change('.$row['id'].');">
 <option value="1">1</option>
 <option value="2">2</option>
 <option value="3">3</option></slect>
 
 </td>
 <td width="15%"><a href="#" onclick="remove('.$row['id'].');return false;" class="remove">remove</a></td>
  </tr>
</table>'}';
?>

查看购物车页面

<div id="main-container">

    <div class="container">
   
     <span class="top-label">
            <span class="label-txt">your order</span>
        </span>
       
        <div class="content-area">
   
      <div class="content">
             
                <?php
    
    $cnt = array();
    $products = array();
    
    foreach($_post as $key=>$value)
    {
     $key=(int)str_replace('_cnt','',$key);
    
     $products[]=$key;
     $cnt[$key]=$value;
    }

    $result = mysql_query("select * from internet_shop where id in(".join($products,',').")");
    
    if(!mysql_num_rows($result))
    {
     echo '<h1>there was an error with your order!</h1>';
    }
    else
    {
     echo '<h1>you ordered:</h1>';
     
     while($row=mysql_fetch_assoc($result))
     {
      echo '<h2>'.$cnt[$row['id']].' x '.$row['name'].'</h2>';
      
      $total+=$cnt[$row['id']]*$row['price'];
     }
  
     echo '<h1>total: $'.$total.'</h1>';
    }
    ?>
               
               
                <div class="clear"></div>
            </div>

        </div>
       
        <div class="bottom-container-border">
        </div>

    </div>

</div>

源码下载地址。
http://down.111cn.net/down/code/php/qitayuanma/2010/1102/21586.html

定义和用法
mkdir() 函数创建目录。

若成功,则返回 true,否则返回 false。

语法
mkdir(path,mode,recursive,context)参数 描述
path 必需。规定要创建的目录的名称。
mode 必需。规定权限。默认是 0777。
recursive 必需。规定是否设置递归模式。
context 必需。规定文件句柄的环境。context 是可修改流的行为的一套选项。

 代码如下 复制代码

<?php
mkdir("testing");
?>

删除目录

定义和用法
rmdir() 函数删除空的目录。

若成功,则该函数返回 true。若失败,则返回 false。

语法
rmdir(dir,context)参数 描述
dir 必需。规定要删除的目录。
context 必需。规定文件句柄的环境。context 是可修改流的行为的一套选项。

说明
尝试删除 dir 所指定的目录。 该目录必须是空的,而且要有相应的权限。

 代码如下 复制代码
<?php
$path = "images";
if(!rmdir($path))
  {
  echo ("could not remove $path");
  }
?>

 

 代码如下 复制代码
<?php
$dirfile="文件夹";
$dirfile=iconv("utf-8","gb2312",$dirfile);//转码,否则会看到windows里面是乱码,但程序能正常操作,读取目录时反过来才看到目录的真正名字。
if(!file_exists($dirfile))//用于判断目录或文件是否存在
mkdir($dirfile);//创建目录
rmdir($dirfile);//删除目录,必须为空目录,否则要先删除里面的所有文件,后面有删除方法
echo "<br>";
?>

 文件创建、删除、读取、转数组

 

 代码如下 复制代码
<?php
$filename="文件.txt";
$filename=iconv("utf-8","gb2312",$filename);//转码,否则会看到windows里面是乱码
file_put_contents($filename,'');//自动创建空文件,如果已存在则删除再创建,具体可以增加file_exists判断,比fopen、fputs、fclose等函数简单。
unlink($filename);//注意文件名都是gb2312编码
file_put_contents($filename,"大家好!rn大家好啊!",file_append);
//看到没,写入两行, 第三个参数可选,表示是以增加方式写入,否则清空内容再写入
echo file_get_contents($filename);//忽略换行读取整个文件
echo "<br>";
$arr=file($filename);//文件按行读到数组里
print_r($arr);
echo "<br>";
readfile($filename);//文件直接输出到屏幕
echo "<br>";
?>

获取url信息、客户端ip地址

 代码如下 复制代码

<?php
//获取域名或主机地址
echo $_server['http_host']."<br>";
//获取网页地址(中间部分)
echo $_server['php_self']."<br>";
//获取网址参数(?后面部分)
echo $_server["query_string"]."<br>";
//来源客户端ip地址
if($_server['http_client_ip']){
$onlineip=$_server['http_client_ip'];
}elseif($_server['http_x_forwarded_for']){
$onlineip=$_server['http_x_forwarded_for'];
}else{
$onlineip=$_server['remote_addr'];
}
echo $onlineip;
echo "<br>";
?>

获取文件修改时间戳、遍历目录文件

 

 代码如下 复制代码
<?php
$filename="文件.txt";
$filename=iconv("utf-8","gb2312",$filename);
$passtime=time()-filectime($filename);//创建时间差,不准,一般不用
echo $passtime;
echo "<br>";
$passtime=time()-filemtime($filename);//修改时间差,用于更新判断,缓冲等判断
echo $passtime;
echo "<br>";
$dir="../";
print_r($arr=scandir($dir));//获得主目录的所有文件和文件夹名称
foreach($arr as $value){
if (!is_dir($dir.$value)) //是否目录,目录还包括"."、".."两个数组,通过判断可以知道是文件还是目录,以及是什么类型的后序名
echo iconv("gb2312","utf-8",$value)."<br>rn";
}
?>

详细实例

 

 代码如下 复制代码

$test="bb|cccs|aaa";

  $array =explode('|',$test);
   $j =1;
   foreach($array as $key){    
    $vote='vote_r'.$j;
    if(0==$rs['vote_times']){
     $n=1;
    }else{
     $n=$rs['vote_times'];www.111cn.net    }
    echo $j,'、',$key,'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',$rs["$vote"],'票&nbsp;&nbsp;&nbsp;',($rs["$vote"]/$n)*100,'%<br>';
    $j++;
   
   }

一款免费的jquery php ajax 投票程序源码,你可以在本教程最后找到这款ajax投票源码下载地址免费下载。
 代码如下 复制代码

/* database config */

$db_host  = '';
$db_user  = '';
$db_pass  = '';
$db_database  = '';

/* end config */

 

$link = mysql教程_connect($db_host,$db_user,$db_pass) or die('unable to establish a db connection');

mysql_select_db($db_database,$link);
mysql_query("set names utf8");

?>


<!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=gb2312" />
<title>jquery php ajax 投票程序源码</title>

<link rel="stylesheet" type="text/css教程" href="demo.css" />

<script type="text/网页特效" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>

<script type="text/javascript" src="script.js"></script>

</head>

<body>

<div id="main">
 

 <hr />

 
<?php

// checking whether the user has voted today:

$voted=false;

$vcheck=mysql_query(" select 1 from sort_votes
      where ip='".$_server['remote_addr']."'
      and date_submit=curdate()");

if(mysql_num_rows($vcheck)==1)
 $voted=true;

// if we are not on the data.php?results page:
if(!array_key_exists('results',$_get))
{
 echo '<ul class="sort">';

 // showing the tutorials by random
 $res = mysql_query("select * from sort_objects order by rand()");

 while($row=mysql_fetch_assoc($res))
 {?>
     <li id="li<?php echo $row['id']?>">
  <div class="tut">
            <div class="tut-img">
                <img src="<?php echo $row['img']?>" width="100" height="100" alt="<?php echo $row['title']?>" />
                <div class="drag-label"></div>
            </div>
           
            <div class="tut-title">
             <a href="<?php echo $row['url']?>" target="_blank" title="open it in a new window!"><?php echo $row['title']?></a>
            </div>
           
            <div class="tut-description"><?php echo $row['description']?></div>
            <div class="clear"></div>
        </div>
        </li>
 <?php } ?>
   
   </ul>
 
 <div class="button-holder">
     <?php if(!$voted):?><a href="" id="submitpoll" class="button">submit poll<span></span></a><?php endif;?>
        <a href="?results" class="button">view the results<span></span></a>
    </div>
 
<?php
}
else require "results.php";
// the above require saves us from having to style another separate page

?>
   
 <div class="clear"></div>   
   

<!-- the form below is not directly available to the user -->

<form action="?results" id="sform" method="post">
<input name="sortdata" id="sortdata" type="hidden" value="" />
</form>

</body>
</html>


results.php

if($_post['sortdata'])
{
 // the data arrives as a comma-separated string,
 // so we extract each post ids:
 $data=explode(',',str_replace('li','',$_post['sortdata']));

 // getting the number of objects
 list($tot_objects) = mysql_fetch_array(mysql_query("select count(*) from sort_objects"));

 if(count($data)!=$tot_objects) die("wrong data!");

 foreach($data as $k=>$v)
 {
  // building the sql query:
  $str[]='('.(int)$v.','.($tot_objects-$k).')';
 }
 
 $str = 'values'.join(',',$str);
 
 // this will limit voting to once a day per ip:
 mysql_query(" insert into `sort_votes` (ip,date_submit,dt_submit)
     values ('".$_server['remote_addr']."',now(),now())");

 // if the user has not voted before today:
 if(mysql_affected_rows($link)==1)
 {
  mysql_query(' insert into `sort_objects` (id,votes) '.$str.'
      on duplicate key update votes = votes+values(votes)');
 }
}

// selecting the sample tutorials and ordering
// them by the votes each of them received:
$res = mysql_query("select * from sort_objects order by votes desc");

$maxvote=0;
$bars=array();

while($row=mysql_fetch_assoc($res))
{
 $bars[]=$row;
 
 // storing the max vote, so we can scale the bars of the chart:
 if($row['votes']>$maxvote) $maxvote = $row['votes'];
}

$barstr='';

// the colors of the bars:
$colors=array('#ff9900','#66cc00','#3399cc','#dd0000','#800080');

foreach($bars as $k=>$v)
{
 // buildling the bar string:
 $barstr.='
  <div class="bar" style="width:'.max((int)(($v['votes']/$maxvote)*450),100).'px;background:'.$colors[$k].'">
   <a href="'.$v['url'].'" title="'.$v['title'].'">'.$v['short'].'</a> 
  </div>';
}

// the total number of votes cast in the poll:
list($totvotes) = mysql_fetch_array(mysql_query("select count(*) from sort_votes"));

?>


<div class="chart">

<?php echo $barstr?>

</div>

<a href="demo.php" class="button">go back<span></span></a>

<div class="tot-votes"><?php echo $totvotes?> votes</div>

源码下载


http://down.111cn.net/down/code/php/toupiaodiaocha/2010/1028/21481.html

文章提供这一款简单的php 文件上传源码哦,如果你是php初学者,可以进来看看这款php 文件上传实例代码哦,好了费话不说多了进来看看这偌大文件上传代码吧。
 代码如下 复制代码

$type=filekzm($_files["filedata"]["name"]);
if ((($type == ".gif")
|| ($type == ".png")
|| ($type == ".jpeg")
|| ($type == ".jpg")
|| ($type == ".bmp"))
&& ($_files["filedata"]["size"] < 200000))
  {
  if ($_files["filedata"]["error"] > 0)
    {
    echo "返回错误: " . $_files["filedata"]["error"] . "<br />";
    }
  else
    {
    echo "上传的文件: " . $_files["filedata"]["name"] . "<br />";
    echo "文件类型: " . $type . "<br />";
    echo "文件大小: " . ($_files["filedata"]["size"] / 1024) . " kb<br />";
    echo "临时文件: " . $_files["filedata"]["tmp_name"] . "<br />";

    if (file_exists( $_files["filedata"]["name"]))
      {
      echo $_files["filedata"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_files["filedata"]["tmp_name"],
      './'.$_files["filedata"]["name"]);
      echo "stored in: " . $_files["filedata"]["name"]."<br />";
   echo "md5效验:".getget("access2008_file_md5")."<br />";
   echo "<br />上传成功!你选择的是<font color='#ff0000'>".getpost("select")."</font>--<font color='#0000ff'>".getpost("select2")."</font>";
      }
    }
  }
else
  {
  echo "上传失败,请检查文件类型和文件大小是否符合标准<br />文件类型:".$type.'<br />文件大小:'.($_files["filedata"]["size"] / 1024) . " kb";
  }
 
function filekzm($a)
{
 $c=strrchr($a,'.');
 if($c)
 {
  return $c;
 }else{
  return '';
 }
}

function getget($v)// 获取get
{
  if(isset($_get[$v]))
  {
  return $_get[$v];
  }else{
  return '';
  }
}

function getpost($v)// 获取post
{
  if(isset($_post[$v]))
  {
   return $_post[$v];
  }else{
   return '';
  }
}
?>

源码下载地址。
http://down.111cn.net/php/2010/1027/21454.html

[!--infotagslink--]

相关文章

  • php 获取用户IP与IE信息程序

    php 获取用户IP与IE信息程序 function onlineip() { global $_SERVER; if(getenv('HTTP_CLIENT_IP')) { $onlineip = getenv('HTTP_CLIENT_IP');...2016-11-25
  • 不打开网页直接查看网站的源代码

      有一种方法,可以不打开网站而直接查看到这个网站的源代码..   这样可以有效地防止误入恶意网站...   在浏览器地址栏输入:   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+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
  • 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开发微信支付的代码分享

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

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

    当来访者浏览器语言是中文就进入中文版面,国外的用户默认浏览器不是中文的就跳转英文页面。 <&#63;php $lan = substr(&#8194;$HTTP_ACCEPT_LANGUAGE,0,5); if ($lan == "zh-cn") print("<meta http-equiv='refresh' c...2015-11-08
  • 几种延迟加载JS代码的方法加快网页的访问速度

    本文介绍了如何延迟javascript代码的加载,加快网页的访问速度。 当一个网站有很多js代码要加载,js代码放置的位置在一定程度上将会影像网页的加载速度,为了让我们的网页加载速度更快,本文总结了一下几个注意点...2013-10-13
  • php怎么用拼音 简单的php中文转拼音的实现代码

    小编分享了一段简单的php中文转拼音的实现代码,代码简单易懂,适合初学php的同学参考学习。 代码如下 复制代码 <?phpfunction Pinyin($_String...2017-07-06
  • js检测用户输入密码强度

    一个用Javascript检测用户输入密码强度的效果代码,以下代码主要是从以下四个方面检测用户输入的密码的强度的,有兴趣的朋友可以自己添加或修改成自己想要的形式! 1. 如果输入的密码位数少于5位,那么就判定为弱。 2. 如果...2015-10-23
  • php有效防止同一用户多次登录

    【问题描述】:同一用户在同一时间多次登录如果不能检测出来,是危险的。因为,你无法知道是否有其他用户在登录你的账户。如何禁止同一用户多次登录呢? 【解决方案】 (1) 每次登录,身份认证成功后,重新产生一个session_id。 s...2015-11-24
  • php导出csv格式数据并将数字转换成文本的思路以及代码分享

    php导出csv格式数据实现:先定义一个字符串 存储内容,例如 $exportdata = '规则111,规则222,审222,规222,服2222,规则1,规则2,规则3,匹配字符,设置时间,有效期'."/n";然后对需要保存csv的数组进行foreach循环,例如复制代...2014-06-07