index.php模块(登录模块)
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
<form action="checklogin.php" method="post">
<tr>
<td width="29%" height="31" align="right" class="text12">用户名:</td>
<td align="left"><input name="username" type="text" size="15"></td>
</tr>
<tr>
<td height="29" align="right" class="text12">密码:</td>
<td align="left"><input name="password" type="password" size="15"></td>
</tr>
<tr>
</td>
</tr>
<tr>
<td height="30" align="right"> </td>
<td align="left"><input type="submit" name="Submit" value="提 交">
<input type="reset" name="Submit2" value="重 置"></td>
</tr>
<tr>
<td height="27" align="right"> </td>
<td><a href="reg.php" class="text12">会员注册</a></td>
</tr>
</form>
</table>
reg.php模块(注册模块)
<?
include("inc/conn.php");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>会员注册</title>
<link href="css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
</head>
<SCRIPT language=javascript>
function CheckPost()
{
if (myform.name.value.length=='')
{
alert("请填写姓名");
myform.name.focus();
return false;
}
if (myform.password.value.length<2)
{
alert("请填写您的密码");
myform.password.focus();
return false;
}
if (myform.enpass.value.length<2)
{
alert("请填写您的确认密码");
myform.enpass.focus();
return false;
}
if (myform.enpass.value!=myform.password.value)
{
alert("新密码和确认密码不一致,请重新输入");
myform.ennewpass.focus();
return false;
}
myform.submit();
}
</SCRIPT>
<body>
<td width="7" valign="top"> </td>
<td width="700" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="423" valign="top"><p> </p>
<table width="93%" height="362" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
<tr>
<td height="360" align="center"><table width="75%" border="0" cellpadding="0" cellspacing="0" class="border">
<form action="save.php?act=add" method="post" name="myform">
<tr>
<tr>
<td height="33" align="right" class="text12">姓名:</td>
<td><input name="name" type="text" id="name">
<span class="STYLE1">*</span></td>
</tr>
<tr>
<td height="33" align="right" class="text12">学号:</td>
<td><input name="username" type="text" id="username">
<span class="STYLE1">*</span></td>
</tr>
<tr>
<td height="33" align="right" class="text12">密码:</td>
<td><input name="password" type="password" id="password">
<span class="STYLE1">*</span></td>
</tr>
<tr>
<td height="33" align="right" class="text12">确认密码:</td>
<td><input name="enpass" type="password" id="enpass">
<span class="STYLE1">*</span></td>
</tr>
<td height="33" align="right" class="text12">性别:</td>
<td><input name="sex" type="radio" value="男" checked>
男
<input type="radio" name="sex" value="女">
女</td>
</tr>
<tr>
<td height="33" align="right"><span class="text12">Email:</span></td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td height="33" align="right"><span class="text12">联系QQ:</span></td>
<td><input name="qq" type="text" id="qq"></td>
</tr>
<tr>
<td width="35%" height="33"> </td>
<td width="65%"><input type="button" name="Submit3" value="提 交" onClick="CheckPost()">
<input type="reset" name="Submit22" value="重 设"></td>
</tr>
</form>
</table></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
checklogin.php(检查登录模块)
<?
session_start();
include("inc/conn.php");
$username=$_POST["username"];
$password=$_POST["password"];
$sql="select * from user where username='$username' and password='$password'";
$query=mysql_query($sql);
if(mysql_num_rows($query)==0)
{
echo "<script>alert('请输入正确的帐号密码!');window.top.location.href='index.php'</script>";
}
else
{
$rs=mysql_fetch_assoc($query);
$_SESSION["username"]=$username;
echo "<script>alert('登陆成功');window.location.href='index.php'</script>";
}
?>
save.php(保存数据模块)
<?
include("inc/conn.php");
$username=$_POST["username"];
$password=$_POST["password"];
$sex=$_POST["sex"];
$email=$_POST["email"];
$qq=$_POST["qq"];
$sql="insert into user(username,password,sex,email,qq) values('$username','$password','$sex','$email','$qq')";
$query=mysql_query($sql);
if ($sql){echo "<script>alert('注册成功,请登录!'); window.location.href='index.php';</script>";}
?>
inc/conn.php数据库连接模块
<?
//ini_set("error_reporting","E_ALL & ~E_NOTICE");
$conn=mysql_connect ("localhost", "root", "") or die("没有连接上啊!");
//127.0.0.1是MySql IP,root是帐号,如果有密码请填写在""中
mysql_select_db("reg") or die("没有连接上"); //guestbook是数据库名
mysql_query("set names gb2312");
?>
整理中出现的问题:
数据库中中文出现乱码。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。