//表单
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form name='form1' action="./041301.php" method="post" enctype='multipart/data-file'>
<p>
用户名:<input type='text' name='user_name' />
</p>
<p>
头像:<input type='file' name='user_img' />
</p>
<p>
密码:<input type='password' name='user_pwd1' />
</p>
<p>
确认密码:<input type='password' name='user_pwd2' />
</p>
<p>
性别:<input type='radio' name='sex' value='1' checked='checked' />男
<input type='radio' name='sex' value='0' />女
</p>
<p>
邮箱:<input type='text' name='user_email' />
</p>
<p>
<input type='submit' name='submit' value='注册' />
<input type='reset' name='reset' value='重置' />
</p>
</form>
</body>
</html>
//数据接收、显示
<?php
$user_name=$_POST['user_name'];
$user_pwd=$_POST['user_pwd1'];
$sex=$_POST['sex'];
$user_email=$_POST['user_email'];
$time=$_SERVER['REQUEST_TIME'];
$host='localhost';
$username='root';
$userpwd='root';
mysql_connect($host,$username,$userpwd);
mysql_select_db('sankea');
mysql_query('set names "utf8"');
$userinfo="insert into cs_user1(user_name,user_password,sex,email,createtime)";
$userinfo.=" values('$user_name','$user_pwd','$sex','$user_email','$time')";
$li= mysql_query($userinfo);
if($li)echo'注册成功!';
else echo mysql_errno().mysql_error();
?>
//数据的读取
<?php
date_default_timezone_set('Etc/GMT');
echo '<meta charset="utf-8">';
$vn=mysql_connect('127.0.0.1','root','root');
mysql_select_db('sankea');
$fetch_sql='select * from cs_user1';
$fetch=mysql_query($fetch_sql);
$rows=[];
while ($row=mysql_fetch_array($fetch,MYSQL_ASSOC)){
$rows[]=$row;
}
// mysql_close($vn);
echo "<table border='0' align='center'>";
echo '<tr><th>ID</th><th>用户名</th><th>地址</th><th>密码</th><th>性别</th><th>邮箱</th><th>注册时间</th><th>修改</th></tr>';
foreach ($rows as $value){
$time=date('Y-n-d H:n:s',$value['createtime']);
if($value['sex']=='1')$sex="男";
else $sex="女";
$tab= "<tr align='center'><td>$value[id]</td><td>$value[user_name]</td><td>$value[img]</td>";
$tab.="<td>$value[user_password]</td><td>$sex</td><td>$value[email]</td><td>$time</td>";
$tab.="<td><a href='./update.php?user_name=".$value[user_name]."' target='_blank'>修改</a></td></tr>";
echo $tab;
}
echo '</table>';
$value[user_name];
?>
//数据修改
<?php
$vn=mysql_connect('127.0.0.1','root','root');
mysql_select_db('sankea');
$sql='update cs_user1 set user_name="'.$_POST[user_name].'",';
$sql.='user_password="'.$_POST[user_password].'",';
$sql.='sex="'.$_POST[sex].'",';
$sql.='email="'.$_POST[email].'"where id='.$_POST[id];
$sq=mysql_query($sql);
if($sq)echo '更改成功!';
else echo mysql_errno().mysql_error();
?>