代码如下 | 复制代码 |
mysql教程_connect('localhost','0731-cn','0731licheng1') or die('sever '); } |
echo "全部导入";
代码如下 | 复制代码 |
$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
本文章来讲二种读取文本文件并显示在网页的php实例了,方法很简单,用fopen,加explode,for就实现了。代码如下 | 复制代码 |
$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;
1.php 连接数据库的示例。
2.php 关闭数据库连接。
3.php 执行sql语句。
4.php 获取sql语句执行错误的信息。
5.php 获取查询结果集。
6.php 获取结果集中的所有记录。
7.php 用php程序显示表中数据。
8.php 分页显示数据。
9.html 提交用户信息的html页面。
10.php 数据插入数据库。
11.php 显示数据信息的php程序。
12.php 添加删除链接的php程序。
13.php 删除数据库数据。
*/
// 1.php 连接数据库的示例。
代码如下 | 复制代码 |
$host = 'localhost'; $conn = mysql_connect($host,$user_name,$password);
|
// 2.php 关闭数据库连接。
代码如下 | 复制代码 |
$host = 'localhost'; $conn = mysql_connect($host,$user_name,$password); if(mysql_close($conn)) |