代码如下 | 复制代码 |
$conn=mysql_connect('localhost','root','root')or die('数据库连接错误'); if($_post[username]){ $sql="select * from users where username='$_post[username]'"; $res=mysql_query($sql)or die("查询失败!"); var username = document.regform.username.value; if(username==""){ var name = document.getelementbyid('username'); //获取用户名文本框 if(xmlhttp.readystate == 4 && xmlhttp.status == 200){ span.style.color = '#cb2121'; //设置span标记颜色为红色 span.style.color = '#00a800';//设置颜色为绿色 xmlhttp.send(null); //发送请求 性别: |
<?
/*
drop table if exists `users`;
create table `users` (
`id` int(10) not null auto_increment,
`username` varchar(50) not null,
`password` varchar(50) not null,
`sex` int(1) not null default '0',
`age` int(10) not null,
`qq` int(15) default null,
`phone` varchar(50) default null,
`email` varchar(50) default null,
`address` varchar(100) default null,
primary key (`id`)
) engine=innodb auto_increment=4 default charset=gbk;
-- ----------------------------
-- records of users
-- ----------------------------
insert into `users` values ('1', 'admin', '21232f297a57a5a743894a0e4a801fc3', '0', '22', '379559090', '666666', '666666@163.com', '武汉');
insert into `users` values ('2', 'root', '63a9f0ea7bb98050796b649e85481845', '0', '20', '1244249796', '8888888', '8888888@163.com', '中国');
insert into `users` values ('3', 'www.111cn.net', '96e79218965eb72c92a549dd5a330112', '0', '20', '1244249796', '8888888', '8888888@163.com', '中国');
本教程下载地址
http://down.111cn.net/down/code/php/xinwenxitong/2010/0812/20183.html
代码如下 | 复制代码 |
class ajaxpage{ var $result; var $anchors; var $total; var $db; var $网页特效p/jsp.html target=_blank >jsp教程agination; function __construct($qry,$starting,$recpage,$jspagination) { $this->db = &$globals['db']; $this->jspagination = $jspagination; $rst = $this->db->query($qry); $numrows = $this->db->num_rows; $qry .= " limit $starting, $recpage"; $this->result = $this->db->get_results($qry,array_a); $next = $starting+$recpage;//the number next time end //$var = ((intval($numrows/$recpage))-1)*$recpage; $page_showing = intval($starting/$recpage)+1;//the str shows on the page bar $total_page = ceil($numrows/$recpage); //total page if($numrows % $recpage != 0){ $last = ((intval($numrows/$recpage)))*$recpage; }else{ $last = ((intval($numrows/$recpage))-1)*$recpage; } $previous = $starting-$recpage; $anc = "<ul id='pagination-flickr'>"; if($previous < 0){ $anc .= "<li class='previous-off'>first</li>"; $anc .= "<li class='previous-off'>previous</li>"; }else{ $anc .= "<li class='next'><a href='网页特效:$this->jspagination(0);'>first </a></li>"; $anc .= "<li class='next'><a href='javascript:$this->jspagination($previous);'>previous </a></li>"; } ################if you dont want the numbers just comment this block############### $norepeat = 3;//no of pages showing in the left and right side of the current page in the anchors $j = 1; $anch = ""; for($i=$page_showing; $i>1; $i--){ $fpreviouspage = $i-1; $page = ceil($fpreviouspage*$recpage)-$recpage; $anch = "<li><a href='javascript:$this->jspagination($page);'>$fpreviouspage </a></li>".$anch; if($j == $norepeat) break; $j++; } $anc .= $anch; $anc .= "<li class='active'>".$page_showing."</li>"; $j = 1; for($i=$page_showing; $i<$total_page; $i++){ $fnextpage = $i+1; $page = ceil($fnextpage*$recpage)-$recpage; $anc .= "<li><a href='javascript:$this->jspagination($page);'>$fnextpage</a></li>"; if($j==$norepeat) break; $j++; } ############################################################ if($next >= $numrows){ $anc .= "<li class='previous-off'>next</li>"; $anc .= "<li class='previous-off'>last</li>"; }else{ $anc .= "<li class='next'><a href='javascript:$this->jspagination($next);'>next </a></li>"; $anc .= "<li class='next'><a href='javascript:$this->jspagination($last);'>last</a></li>"; } $anc .= "</ul>"; $this->anchors = $anc; $this->totalstr = "page : $page_showing <i> of </i> $total_page . total records found: $numrows"; } } |
代码如下 | 复制代码 |
mysql教程_connect('localhost','0731-cn','0731licheng1') or die('sever '); } |
echo "全部导入";
代码如下 | 复制代码 |
$file = "./text.txt"; $text = fread(fopen($file,"r"),filesize($file)); $line = explode(" ",$text); echo "<table width=300 border=1 cellspacing=0 cellpadding=0>"; for($i = 0; $i <= count($line); $i++){ $txt = explode(" ",$line[$i]); echo "<tr><td>".$txt[0]."</td><td>".$txt[1]."</td><td>".$txt[2]."</td><td>".$txt[3]."</td></tr>"; } echo "</table>"; |
//方法二
代码如下 | 复制代码 |
$content = file_get_contents('test.txt'); $arr = explode(" ", $content); foreach ($arr as $v) { echo "</table>"; |
//其实不有一个方法来实现上的实例,file函数哦,这个我也不说多了。查查就知道了,它读出内容直接保存到数据,就不用我们使用explode函数了。
/*
文本文本格式如下
读取一个文本文件内容如下
1 aaaa bbba ccca
2 aaaa bbbb cccb
3 aaaa bbbc cccc
3 aaaa bbbc cccc
这是一款利用mysql php实例的用户注册代码,比较简单,就是把html提交过来的数据保存到mysql数据库。
include('global.php');
代码如下 | 复制代码 |
if($_post['sub']){ |
<!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>
<link rel="stylesheet" type="text/css教程" href="css/reg_log.css" />
</head>
<body>
<form id="myform" name="myform" method="post" action="register.php">
<div id="top">注册 <a href="login.php">登录</a></div>
<div id="content">
<div class="c1">请填写以下必填信息完成注册</div>
<div class="c2"><span>带红色*的都是必填项目,若填写不全将无法注册</span></div>
<div class="cinput"><dl>
<dt>用户名<font color="red">*</font></dt>
<dd><input id="username" name="username" type="text" maxlength="12" /></dd>
<dd id="user_prompt" class="prompt">大小写英文字母、汉字、数字、下划线组成的长度 3-12 个字节以内</dd>
</dl></div>
<div class="cinput"><dl>
<dt>密 码<font color="red">*</font></dt>
<dd><input id="password1" name="password1" type="password" maxlength="16" /></dd>
<dd id="pwd1_prompt" class="prompt">最小长度:6 最大长度:16,仅限字母、数字及_,字母区分大小写</dd>
</dl></div>
<!--检测密码强度-->
<div class="cinput" style="padding-bottom:0px;"><!--ie6 hack-->
<div class="chkpwd">
<span id="cp1_prompt" class="cp1"></span><span id="cp2_prompt" class="cp2"></span>
<span id="cp3_prompt" class="cp3"></span>
</div>
</div>
<div class="cinput" style="padding-top:0px;"><dl>
<dt>确认密码<font color="red">*</font></dt>
<dd><input id="password2" name="password2" type="password" maxlength="16" /></dd>
<dd id="pwd2_prompt" class="prompt">请再输入一遍您上面填写的密码</dd>
</dl></div>
<div class="cinput"><dl>
<dt>email<font color="red">*</font></dt>
<dd><input id="email" name="email" type="text" /></dd>
<dd id="email_prompt" class="prompt">请填写真实并且最常用的邮箱</dd>
</dl></div>
<div style="clear:both"></div>
</div>
<div id="bottom">
<input class="btn1" type="submit" name="sub" value="提交注册" id="checkall" />
<input class="btn2" type="reset" name="reset" value="重置" onclick="return sub(this.form)" />
</div>
</form>
</body>
</html>
数据库结构
create table `hl`.`hl_member` (
`id` int( 4 ) not null auto_increment comment '自动编码',
`username` varchar( 100 ) not null comment '用户名称',
`password` varchar( 200 ) not null comment '用户密码',
`answer` varchar( 100 ) not null comment '密保答案',
`question` varchar( 100 ) not null comment '密保问题',
`email` varchar( 100 ) not null comment 'email',
`realname` varchar( 200 ) not null comment '登录限制',
`birthday` date not null comment '出生日期',
`telephone` varchar( 20 ) not null comment '电话号码',
`qq` varchar( 15 ) not null comment 'qq号码',
`count` int( 1 ) not null comment '登录限制',
`active` int( 1 ) not null comment '是否激活',
primary key ( `id` )
) engine = innodb character set gb2312 collate gb2312_chinese_ci;