当前位置: 澳门新濠3559 > 编程 > 正文

echo"你是不是在灌水呀,register.php(判断注册用户

时间:2019-11-22 20:51来源:编程
======APPRE.PHP========== $strlen=strlen; if{ echo " 有三个文件: 第一是: 一.mysql数据库 ?php class conn{ function __construct(){   require("config.php");   $conn = @mysql_connect($host,$root,$pass);   @mysql_select_db($db);

======APPRE.PHP========== $strlen=strlen; if{ echo "

有三个文件: 第一是:

一.mysql数据库

<?php
class conn{
function __construct(){
  require("config.php");
  $conn = @mysql_connect($host,$root,$pass);
  @mysql_select_db($db);
  if(!$conn){
   echo "无法连接".mysql_errno() . ":" . mysql_error() ;
   exit;
  }
}
function query($sql){
  $result = @mysql_query($sql);
  if (!$result) {
   echo mysql_errno().":".mysql_error();
   exit;
  }
  return $result;
}
function next($result){
  return  @mysql_fetch_array($result);
}
function count_row($result){
  $row = @mysql_num_rows($result);
  return $row;
}
function close($result){
  @mysql_free_result($result);
  @mysql_close();
}
}
class fenye extends conn{
public $sql;
public $page;
public $countpage;
public $pagesize;
public $result;
function __construct($sql,$page,$pagesize){
  $this->sql = $sql;
  $this->page = $page;
  $this->countpage = $countpage;
  $this->pagesize = $pagesize;
  parent::__echo"你是不是在灌水呀,register.php(判断注册用户名是否正确和是否重复。construct();
  $result = parent::query($sql);
  $num = parent::count_row($result);
  $this->countpage = ceil($num/$pagesize);
  $a = ($page-1)*$pagesize;
  $limit = "limit $a,$pagesize";
  $this->sql = $sql.$limit;
  $this->result = parent::query($this->sql);
}
function getlimit(){
  return $this->sql;
}
    function next(){
     return parent::next($this->result);
    }
function foor(){
  $a = $this->page -1;
  $b = $this->page +1;
  if ($this->page == 1) {
   echo "首页"."    ";
  }else  echo "<a href='?page=1'>首页</a>"."    ";
  if($this->page >1)
     echo "<a href='?page=$a'>上页</a>"."    ";
  else  echo "上页    ";
  for ($i =1;$i <= $this->countpage;$i++){
   echo "<a href='?page=$i'>$i</a>"."       ";
  }
  if($this->page < $this->countpage)
      echo "<a href='?page=$b'>下页</a>"."    ";
  else  echo "下页    ";
  if ($this->page == $this->countpage) {
   echo "末页"."    ";
  }else   echo "<a href='?page=$this->countpage'>末页</a>";
  #######################
 
}
}
####################
if (isset($_GET['page'])) {
$page = $_GET['page'];
}else  $page = 1;
$sql = "select * from guestbook ";
$pagesize =3;
$p = new fenye($sql,$page,$pagesize); 
$sql = $p->getlimit();
$result = $p->query($sql);
while($row = $p->next()){
echo $row['id']."<br>";
}
$p->foor();
$p->close($result);
?>

"; echo "

当前位置:主页>>注册页面

 代码如下

 

"; echo"你是不是在灌水呀?为防止部分网友善意的灌水,本站规定你所提交的文章"; echo"

请设定用户名:(3-15位)

<?php
$conn=mysql_connect("localhost", "root", "123456") or die("数据库连接失败");
mysql_select_db("test") or die("选择数据库失败");;
$sql="select * from user";
$data=mysql_query($sql);
echo '<table border="1" align="center" width="800">'
while($row=mysql_fetch_assoc($result)){
echo '<tr>';
foreach($row as $col){
echo '<td>'.$col.'</td>';
}
echo '</tr>';
};
echo '</table>';
mysql_close();

"; echo"

第二个是:register.php(判断注册用户名是否正确和是否重复,然后输出注册的详细表单)

补充

"; echo"的长度必须大于50个汉字。请你重新提交文章。谢谢"; echo"

当前位置:主页>>注册页面>>详细资料

 代码如下

"; echo"

if{ echo"
用户名不能为空。请返回
"; include("foot.inc.php"); exit<3 || strlen{ echo"
用户名的长度不符合要求。请返回
"; include("foot.inc.php"); exit(); } if (!eregi("^[_a-z0-9-]+*$", $name)) { echo"
注册名只能由字母数字组成.请返回
"; include("foot.inc.php"); exit {$conn=@mysql_connect("localhost"); $sql=@mysql_select_db("jocky",$conn); $result=@mysql_query("select * from user1 where name='$name'" ,$conn); if{ if(@mysql_fetch_object{ echo"
对不起,已经有相同的用户名!请返回.
";} else{$conn=@mysql_connect("localhost"); $sql=@mysql_select_db("jocky",$conn); $sqldo="insert into user1 values "; @mysql_query; echo"
你好,"; echo"$name"; include("zhuce.php"); @mysql_close;} include("foot.inc.php"); exit(); } } ?>

 // 从表中提取信息的sql语句
$strsql="SELECT * FROM `gbook`";
// 执行sql查询
$result=mysql_db_query($mysql_database, $strsql, $conn);
// 获取查询结果
$row=mysql_fetch_row($result);

"; echo" "; echo""; echo"

第三个是:check.php(判断注册资料是否正确,然后插入数据库,重新登录)

 
echo '<font face="verdana">';
echo '<table border="1" cellpadding="1" cellspacing="2">';

"; echo"

当前位置:主页>>注册页面>>详细资料

// 显示字段名称
echo "</b><tr></b>";
for ($i=0; $i<mysql_num_fields($result); $i++)
{
  echo '<td bgcolor="#000F00"><b>'.
  mysql_field_name($result, $i);
  echo "</b></td></b>";
}
echo "</tr></b>";
// 定位到第一条记录
mysql_data_seek($result, 0);
// 循环取出记录
while ($row=mysql_fetch_row($result))
{
  echo "<tr></b>";
  for ($i=0; $i<mysql_num_fields($result); $i++ )
  {
echo '<td bgcolor="#00FF00">';
echo $row[$i];
echo '</td>';
  }
  echo "</tr></b>";
}
  
echo "</table></b>";
echo "</font>";
// 释放资源
mysql_free_result($result);
// 关闭连接
mysql_close($conn); 

"; echo"

if($truename==""){ echo"
真实姓名不能为空。请返回
"; include("foot.inc.php"); exit(); } if($password==""||$repassword==""){ echo"
密码不能为空。请返回
"; include("foot.inc.php"); exit(); } if($repassword!=$password){ echo"
两次输入的密码不一样。请返回
"; include("foot.inc.php"); exit(); } if<6 || strlen{ echo"
密码的长度不符合要求。请返回
"; include("foot.inc.php"); exit(); } if($pwwhat==""){ echo"
密码提示问题不能为空。请返回
"; include("foot.inc.php"); exit(); } if{ echo"
密码提示答案不能为空。请返回
"; include("foot.inc.php"); exit(); } if($personalid==""){ echo"
身份证号码不能为空。请返回
"; include("foot.inc.php"); exit(); } if!=15 or strlen{ echo"
输入的身份证号码不是15位或18位。请返回
"; include("foot.inc.php"); exit(); }*/ if($year=="" || $month=="" || $day==""){ echo"
出生年月日没有填。请返回
"; include("foot.inc.php"); exit!=4 || strlen!=2 || strlen{ echo"
输入的年月日不正确。请返回
"; include("foot.inc.php"); exit(); } if (!eregi("^[_.0-9a-z-]+@+[a-z]{2,3}$",$email)) { echo"
E-Mail地址格式不对。请返回
"; include("foot.inc.php"); exit(); } if{ echo"
联系的电话不能为空。请返回
"; include("foot.inc.php"); exit!=11 || strlen!=12 || strlen{ echo"
联系的电话长度不正确。请返回
"; include("foot.inc.php"); exit(); } if($gender==""){ $null1="空";} if{ $null2="空";} if{ $null3="空";} if{ $null4="空";} $birthday="$year.-.$month.-.$day"; $time=time(); $conn=@mysql_connect("localhost"); $sql=@mysql_select_db("jocky",$conn); $result=@mysql_query("select * from user1 where name='$name'" ,$conn); $sqldo="insert into user1 (name,truename,password,pwwhat,pwan,personalid,gender,xueli,birth,email,tel,money,addr,time) values('$name','$truename','$password','$pwwhat','$pwan','$personalid','$null1','$null2',"; $sqldo.="'$birthday','$email','$tel','$null3','$null4','$time')"; $query=@mysql_query; if{ echo"
恭喜你,你已注册成功!请登录
"; exit(); }else{ echo"
服务器忙,不能为你注册,请稍后再注册!回主页
"; } @mysql_close; ?>

二.pdo_mysql(推荐)

"; echo"

连接:

"; echo"

 代码如下

| 返回首页

$dsn = "mysql:host=localhost;dbname=test";
$username = 'root';
$password = '123456';
$options = array(
   PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);

"; echo"

$pdo = new PDO($dsn, $username, $password, $options);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
增:

|推荐说明 |

方法1: 绑定关联数组

"; echo"

$str=$pdo->prepare("INSERT INTO `user` (`username`, `password`) VALUES (:username,:password)");
$str->execute(array(":username"=>"test", ":password"=>"passwd"));

搜索文章 |

方法2: 绑定索引数组

"; echo"

$str=$pdo->prepare("INSERT INTO `user` (`username`, `password`) VALUES (?,?)");
$str->execute(array("test", "passwd"));
删:

阅读文章 |

$str=$pdo->prepare("delete from user where id > 3");
$str->execute();

"; echo"

改:

联系站长 |

$str=$pdo->prepare("UPDATE `user` SET username=:username,password=:password where id=:id");
$str->execute(array(":username"=>"test", ":password"=>"passwd", ":id"=>"3"));
查:
方法1: 单个取出,循环遍历,返回到数组

"; echo"

$str=$pdo->prepare("select * from user where id > :id  order by id");
$str->execute(array(":id"=>2));
$str->setFetchMode(PDO::FETCH_ASSOC);
//共三种:1.PDO::FETCH_BOTH(默认)  2.FETCH_ASSOC  3.FTECH_NUM
 
while($data=$str->fetch()){
print_r($data);
echo '<br>';
}

"; echo"

方法2: 全部取出,返回到二维数组

"; exit; } $strlen=strlen; if{ echo"

$str=$pdo->prepare("select * from user order by fid");
$str->execute();
$data=$str->fetchAll(PDO::FETCH_NUM);
print_r($data);

"; echo"

方法3:单个取出,循环遍历,绑定字段名到变量

"; echo"请你正确输入你的名字"; echo"

$str=$pdo->prepare("select fid,username,password from user order by id");
$str->execute();
 
$str->bindColumn("id",$id);
$str->bindColumn("username",$username);
$str->bindColumn(3,$password);
 
while($str->fetch()){
echo "$id | $username | $password <br>";
}
echo "总记录数:".$str->rowCount()."<br>";
echo "总字段数:".$str->columnCount()."<br>";

"; echo"

二.mysqli

"; echo"【重新提交文章】 "; echo"【返回主页】"; echo"

 代码如下

"; echo"

(用mysqli链接MYSQL数据库)
requery_once("config.ini.php");
$mysqliObj = new mysqli($dbhost,$dbuser,$dbpwd,$dbname);
if(mysqli_connect_errno()){
 echo "连接失败".mysqli_connect_error();
 exit();
}
$mysqliObj->query("set name $charName");

"; echo"

(其他操作)  

"; echo"

查询

(单条查询)
$sql = "drop table  if exists user;";
$mysqliObj->query($sql);
 
(多条查询)
$musqliObj->multip_query($sql)      

"; echo"

返回执行$sql受影响的行数()

if($mysqliObj->query($sql))
echo $mysqliObj->affected_rows;  

| 返回首页

insert 插入时,返回插入的id (很有用)

 $num = $mysqliObj->insert_id;

<?php
$mysqli=new mysqli("localhost", "root", "123456", "test");
$sql="select * from user  order by id";
$result=$mysqli->query($sql);
echo '<table align="center" border="1" width="800">';
while($row=$result->fetch_assoc()){
echo '<tr>';
foreach($row as $col){
echo '<td>'.$col.'</td>';
}
echo '</tr>';
}
echo '</table>';
$mysqli->close();

"; echo"

三种处理查询结果

 

 代码如下

$sql = "select * from user";
 $result = $mysqli->query($sql);
 
(1)fetch_row()   返回索引数组
fetch_row()
while(list($id,$name,$pwd)=$result->fetch_row()){
echo "id: ".$id." name:".$name."  pwd:".$pwd."<br>";
 
}
(2)fetch_assoc()  返回关联数组
fetch_assoc()
while ($row = $result->fetch_assoc()){
 echo "id:".$row["userId"]." name:".$row["userName"]."  pwd:".$row["password"]."<br>";
}
 
(3)fetch_object()返回对象
while($row = $result->fetch_object()){
echo "id:".$row->userId." name:".$row->uerName."  pwd:".$row->password."<br>";
 
}

|推荐说明 |

"; echo"

搜索文章 |

"; echo"

阅读文章 |

"; echo"

联系站长 |

"; echo"

"; echo"

"; exit; } @$conn=mysql_connect("localhost","user","password"); mysql_select_db; $sql="select*from article where articlename='$articlename'"; $result=mysql_query; if{ if(mysql_fetch_object{ echo"

"; echo"

"; echo"你所推荐的文章已经存在了"; echo"

"; echo"

"; echo"重新推荐下一篇文章"; echo"

"; echo"

"; echo"如果你确信本站没有你所推荐的文章,请你点这里与此同时Bamboo联系"; echo"

"; echo"

"; echo"【重新发表新的文章】"; echo"【返回主页】"; echo"

"; echo"

"; mysql_close; echo"

"; echo"

"; echo"

| 返回首页

"; echo"

|推荐说明 |

"; echo"

搜索文章 |

"; echo"

阅读文章 |

"; echo"

联系站长 |

"; echo"

"; echo"

"; exit;} } $sql="select *from article where name=$name"; $result=mysql_query; if{ if(mysql_fetch_object{ echo"

"; echo"

"; echo"

"; echo"本站数据库记录显示已经有一个和你同名的记录,请你换一个名字重新发表文章"; echo"

"; echo"

"; echo"重新发表文章"; echo"返回主页"; echo"

"; echo"

"; mysql_close; echo"

"; echo"

"; echo"

| 返回首页

"; echo"

|推荐说明 |

"; echo"

搜索文章 |

"; echo"

阅读文章 |

"; echo"

联系站长 |

"; echo"

"; echo"

"; exit; } } echo $webadd1; $sql="insert into article(name,webname,webadd,weblogo,articlename,articleauthor,articlemsg) values ('$name','$webname','$webadd','$weblogo','$articlename' ,'$articleauthor' ,'$articlemsg' )"; //echo mysql_errno().":".mysql_error()."
"; if(mysql_query{ echo"

"; echo"

"; echo"谢谢你,斑竹园的发展离不开你的支持。你提交的文章已经接受"; echo"

"; echo"

"; echo"【提交另一篇文章】"; echo"【返回主页】"; echo"

"; echo"

"; mysql_close; } else{ echo"

"; echo"

"; echo"对不起,你提交的文章出现错误,请你重新提交"; echo"

"; echo"

"; echo"【重新提交】"; echo"【返回主页】"; echo"

"; echo"

"; mysql_close; } echo"

"; echo"

"; echo"

| 返回首页

"; echo"

|推荐说明 |

"; echo"

搜索文章 |

"; echo"

阅读文章 |

"; echo"

联系站长 |

"; echo"

"; echo"

"; ?>

编辑:编程 本文来源:echo"你是不是在灌水呀,register.php(判断注册用户

关键词: