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;
代码如下 | 复制代码 |
$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
本章介绍如何使用PHP操作MySQL数据库,包括连接数据库 ,关闭数据库连接 示例 执行SQL语句 获取查询结果集,获取SQL语句执行错误的信息,获取结果集中的所有记录,分页显示数据,数据插入数据库,提交用户信息的HTML页面,显示数据信息的PHP程序,添加删除链接的PHP程序,删除数据库数据可以说是一部完整的php mysql入门基础教程哦。
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)) |
本章介绍一个基于文本的简易BLOG系统,当然我们可以利用这款blog系统的开发,很好的理解php网站开发原理了,其实网站开发容易于博客开哦,下面来看功能模块。
post.php 读文件并显示日志内容的php程序。
page.html 显示日志文章的html文档。
style.css教程 页面显示效果的css代码。
add.php 添加blog文章的php程序。
config/auth.php 用户名和密码配置文件。
index.php blog首页程序。
edit.php 编辑blog文章的程序。
delete.php 删除blog文章的程序。
archives.php 归档显示blog文章的程序。
logout.php 退出登录的程序。
*/
//post.php 读文件并显示日志内容的php程序。
代码如下 | 复制代码 |
<?php $post_data = array(); $path = substr($_get['entry'],0,6); //日志存储目录 if(file_exists($file_name)) $content_array = explode('|', $result); $post_data['subject'] = $content_array[0]; <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <div id="container"> <body> |
//page.html 显示日志文章的html文档。
代码如下 | 复制代码 |
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <div id="container"> <body> |
这里讲的文件操作主要是讲php获取文件的主要信息,判断文件的性质,获取文件名和目录名等哦。下面看三个实例
代码如下 | 复制代码 |
//获取文件的主要信息。 if(is_dir($file)) if(is_file($file)) if(is_readable($file)) if(is_writeable($file)) $file_name = basename($path); echo "完整路径:".$path; echo "其中目录名为:".$dir_name; if(file_exists($file)) if(file_exists($dir)) |