您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。