index.php模塊(登錄模塊)
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供朗縣網(wǎng)站建設、朗縣做網(wǎng)站、朗縣網(wǎng)站設計、朗縣網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、朗縣企業(yè)網(wǎng)站模板建站服務,十載朗縣做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。
<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("請?zhí)顚懶彰?);
myform.name.focus();
return false;
}
if (myform.password.value.length<2)
{
alert("請?zhí)顚懩拿艽a");
myform.password.focus();
return false;
}
if (myform.enpass.value.length<2)
{
alert("請?zhí)顚懩拇_認密碼");
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">聯(lián)系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(保存數(shù)據(jù)模塊)
<?
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數(shù)據(jù)庫連接模塊
<?
//ini_set("error_reporting","E_ALL & ~E_NOTICE");
$conn=mysql_connect ("localhost", "root", "") or die("沒有連接上??!");
//127.0.0.1是MySql IP,root是帳號,如果有密碼請?zhí)顚懺?"中
mysql_select_db("reg") or die("沒有連接上"); //guestbook是數(shù)據(jù)庫名
mysql_query("set names gb2312");
?>
整理中出現(xiàn)的問題:
數(shù)據(jù)庫中中文出現(xiàn)亂碼。
名稱欄目:用戶注冊和用戶登錄簡單代碼
本文URL:http://m.rwnh.cn/article6/ipjsig.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設、網(wǎng)站導航、微信公眾號、App設計、網(wǎng)站維護、全網(wǎng)營銷推廣
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)