实战php制作会员管理系统(二)
现在我们开始创建注册页面,代码如下:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>会员管理系统</title>
<style>
.main{margin: 0 auto;text-align: center;width: 80%;}
h2{font-size: 16px;}
h2 a{text-decoration: none;margin-right: 15px;}
h2 a:hover{color: red;}
.current{color: blue}
</style>
</head>
<body>
<div class="main">
<h1>会员管理系统</h1>
<h2>
<a href="index.php">首页</a>
<a href="singup.php" class="current">注册</a>
<a href="login.php">登录</a>
<a href="modify.php">修改</a>
<a href="admin.php">后台</a>
</h2>
<form action="postReg.php"method="post">
<table align="center" border="1" style="border-collapse: collapse"cellpadding="10"cellspacing="0">
<tr>
<td align="right">用户名:</td>
<td><input name="username"></td>
</tr>
<tr>
<td align="right">密码:</td>
<td><input name="password"></td>
</tr>
<tr>
<td align="right">确认密码:</td>
<td><input name="cpw"></td>
</tr>
<tr>
<td align="right">邮箱:</td>
<td><input name="email"></td>
</tr>
<tr>
<td align="right">性别:</td>
<td>
<input name="sex" type="radio" checked value="1">男
<input name="sex" type="radio" value="0">女
</td>
</tr>
<tr>
<td align="right">爱好:</td>
<td>
<input name="fav[]" type="checkbox"value="打游戏">打游戏
<input name="fav[]" type="checkbox"value="听音乐">听音乐
<input name="fav[]" type="checkbox"value="逛街">逛街
</td>
</tr>
<tr>
<td><input type="submit"value="提交"></td>
<td><input type="submit"value="重置"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
简单介绍下这个页面吧,猛的一看和首页差不多,其实不然,我们多了一个form表单action="postReg.php"method="post
action指的是要发送的地址,method指的是发送方式,这里我们用post
接收文件为postReg.php,因此我们要创建此文件,代码如下:
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$cpw = $_POST['cpw'];
$email= $_POST['email'];
$sex = $_POST['sex'];
$fav = $_POST['fav'];
$fav=implode(",",$_POST['fav']);
$username指的是用户名,下面分别是密码,确认密码,邮箱,性别,爱好
方式其实是利用$_POST['username']接收到赋值给$username,其他的也一样,username这个值是form表单里面的name值
最后一个返回的其实是一个数组,爱好包含多种,属于多选框,而性别返回的会是0或者1,因为我们上面form表单里面填入的就是0和1,也可以写男和女
至此第二步告一段落
阅读剩余
THE END