sampleindex.php
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</head>
<h1>用户注册</h1>
<form action="register01.php" method="post">
<table border='1'><tr><td> 用户名:</td> <td><input type="text" name="username"/></td></tr>
<tr><td> 密码:</td> <td><input type="password" name="password"/></td></tr>
<tr><td colspan="2">性别:<input type="radio" name="sex" value="female" />女
<input type="radio" name="sex" value="male" />男
</td></tr>
<tr><td>
你有什么兴趣爱好:</td><td>
<input type="checkbox" name="hobby[]" value="唱歌" />唱歌<br />
<input type="checkbox" name="hobby[]" value="跳舞" />跳舞<br />
<input type="checkbox" name="hobby[]" value="游泳" />游泳<br />
<input type="checkbox" name="hobby[]" value="骑马" />骑马<br />
<input type="checkbox" name="hobby[]" value="射箭" />射箭<br />
</td></tr>
<tr><td>你的所在地是:</td><td><select name="city">
<option value="beijing">北京</option>
<option value="tianjin">天津</option>
<option value="shanghai">上海</option>
<option value="ningbo">宁波</option>
</select></td></tr>
<tr><td colspan="2"><textarea rows="10" name="intro" cols="33"></textarea></td></tr>
<tr><td> <input type="submit" value="用户注册" /></td>
<td> <input type="reset" value="重新填写" /></td></tr>
</table>
</form>
</html>
读取register01.php
<?php
echo "<pre>";
echo print_r($_POST);
echo "</pre>";
//以上是全部的数据了
//下面是特定的读取
$name=$_POST['username'];
$pwd=$_POST['password'];
$xinbgie=$_POST['sex'];
//接收数组checkbox
$hobbies=$_POST['hobby'];
$intro=$_POST['intro'];
$city=$_POST['city'];
echo "个人信息如下:<br/>";
echo "用户名是:$name ";
echo "性别是:$xinbgie ";
echo "密码是:$pwd <br/>";
echo "此人的爱好有:<br/>";
for($i=0;$i<count($hobbies);$i++){
echo "$hobbies[$i] <br/>";
}
echo "个人信息介绍如下:<br/>";
echo "我来自:$city<br/>$intro<br/>";
?>
增删等
create table empAdminTable(
id int primary key,
name varchar(32) not null,
password varchar(128) not null
);
create table empTable(
id int primary key auto_increment,
name varchar(64) not null,
grade tinyint,
email varchar(64) not null,
salary float
);
//添加初始化数据
insert into empAdminTable(id,name,password) values (100,'admin',md5('admin123'));
insert into empTable(name,grade,email,salary) values ('zhangsan',1,'zhangsan@163.com',250);
insert into empTable(name,grade,email,salary) values ('lisi01',1,'lisi01@sohu.com',250);
insert into empTable(name,grade,email,salary) values ('lisi02',1,'lisi02@sohu.com',300);
insert into empTable(name,grade,email,salary) values ('lisi03',1,'lisi03@163.com',450);
insert into empTable(name,grade,email,salary) values ('lisi04',1,'lisi04@163.com',237);
insert into empTable(name,grade,email,salary) values ('lisi05',1,'lisi@sohu.com',200);
测试数据,快速添加几十万的数据。
insert into empTable(name,grade,email,salary) select name,grade,email,salary from empTable;
查看总共几条数据
select count(*) from empTable;