u_signup.htmhtml
創(chuàng)新互聯(lián)公司是一家從事企業(yè)網(wǎng)站建設(shè)、做網(wǎng)站、網(wǎng)站制作、行業(yè)門戶網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)制作的專業(yè)網(wǎng)站建設(shè)公司,擁有經(jīng)驗(yàn)豐富的網(wǎng)站建設(shè)工程師和網(wǎng)頁設(shè)計(jì)人員,具備各種規(guī)模與類型網(wǎng)站建設(shè)的實(shí)力,在網(wǎng)站建設(shè)領(lǐng)域樹立了自己獨(dú)特的設(shè)計(jì)風(fēng)格。自公司成立以來曾獨(dú)立設(shè)計(jì)制作的站點(diǎn)上千家。
head
/head
title歡迎注冊(cè)網(wǎng)絡(luò)圖書銷售信息管理系統(tǒng)/title
body
p align="center" class="style"會(huì)員注冊(cè)/p
hr
form name="form1" method="post" action="u_signup.php"
p align="center"身份證號(hào)input name="u_sfzh" type="text" maxlength="18"/p
p align="center"會(huì)員姓名input name="u_hyxm" type="text" /p
p align="center"會(huì)員密碼input name="u_hymm1" type="password" /p
p align="center"密碼確認(rèn)input name="u_hymm2" type="password" /p
p align="center"聯(lián)系電話input name="u_lxdh" type="text" /p
p align="center"聯(lián)系地址input name="u_lxdz" type="text" /p
p align="center"銀行名稱input name="u_yhmc" type="text" /p
p align="center"銀行卡號(hào)input name="u_yhkh" type="text" /pp align="center"input name="u_return" type="submit" value="會(huì)員注冊(cè)"/p
/form
/body
/html u_signup.php?php
//驗(yàn)證身份證號(hào)
$sfzh=$_POST['u_sfzh'];
if(empty($sfzh))
die("身份證號(hào)不能為空");
else if(strlen($sfzh)!=18)
die("身份證號(hào)應(yīng)為18位");
else if(!is_numeric($sfzh))
die("身份證號(hào)應(yīng)為18位數(shù)字");//驗(yàn)證會(huì)員姓名
$hyxm=$_POST['u_hyxm'];
if(empty($hyxm))
die("會(huì)員姓名不能為空");
else if(strlen($hyxm)4)
die("會(huì)員姓名應(yīng)最少2個(gè)字符");
//驗(yàn)證會(huì)員密碼
$hymm1=$_POST['u_hymm1'];
$hymm2=$_POST['u_hymm2'];
if(empty($hymm1) or empty($hymm2))
die("會(huì)員密碼不能為空");
else if(strlen($hymm1)4 or strlen($hymm2)4 )
die("會(huì)員密碼至少是4個(gè)字符");
else if($hymm1!=$hymm2)
die("兩次輸入的密碼不一致");//驗(yàn)證聯(lián)系電話
$lxdh=$_POST['u_lxdh'];
if(empty($lxdh))
die("聯(lián)系電話不能為空");
else if(!is_numeric($lxdh))
die("聯(lián)系電話應(yīng)為數(shù)字");//驗(yàn)證聯(lián)系地址
$lxdz=$_POST['u_lxdz'];
if(empty($lxdz))
die("聯(lián)系地址不能為空");
else if(strlen($lxdz)6)
die("聯(lián)系地址應(yīng)最少6個(gè)字符");//驗(yàn)證銀行名稱和銀行卡號(hào)
$yhmc=$_POST['u_yhmc'];
$yhkh=$_POST['u_yhkh'];
if(empty($yhmc) or empty($yhkh))
die("銀行名稱和銀行卡號(hào)不能為空");
else if(strlen($yhmc)4 or strlen($yhkh)4 )
die("銀行名稱和銀行卡號(hào)至少是4個(gè)字符");//獲取系統(tǒng)日期和時(shí)間
$v_time=date("Y-m-d H:i:s");include "conn.php";mysql_query("set names 'GB2312'");//判斷是否存在相同用戶
//查詢數(shù)據(jù)的sql語句形式:select * from member where 身份證號(hào)='123456789012345678'
$v_find="select * from member where 身份證號(hào)='".$sfzh."'";
//echo($v_find);
//echo("br");
$result=mysql_query($v_find,$conn);
$record=mysql_num_rows($result);
if($record0)
die($sfzh."該會(huì)員身份證號(hào)已經(jīng)注冊(cè),不得重復(fù),注冊(cè)失敗。");//注冊(cè)用戶
//插入數(shù)據(jù)的sql語句形式:insert into member values('11111111111111','1111',''...)
$v_insert="insert into member values('".$sfzh."','".$hyxm."','".$hymm1."','".$lxdh."','".$lxdz."','".$yhmc."','".$yhkh."','".$v_time."',0)";//echo($v_insert);
//echo("br");$result=mysql_query($v_insert);echo("注冊(cè)成功");?conn.php?php
$host="localhost";
$user="root";
$password="123456";$conn=mysql_connect($host,$user,$password);
if(!$conn)
die("連接MySQL服務(wù)器失敗。".mysql_error());$dbase="bookstore";
$db_select=mysql_select_db($dbase,$conn);
if(!$db_select)
die("連接MySQL數(shù)據(jù)庫失敗。".mysql_error());
?
注冊(cè):
用戶名 :手機(jī)號(hào)或者郵箱
密碼:規(guī)定6-16位字符或者6-12位,不能出現(xiàn)_、等字符,規(guī)定只能數(shù)字和英文字符組成
驗(yàn)證碼:隨機(jī)圖片
ajax提交時(shí)驗(yàn)證用戶名是否合法(郵箱或手機(jī)號(hào)驗(yàn)證)。去掉首尾空白。判斷數(shù)據(jù)格式(過濾html標(biāo)簽,防止sql注入)
判斷密碼格式和長度
判斷驗(yàn)證碼正確
三者都正確。提交到后臺(tái)處理:
查詢用戶名是否存在,如果存在,不能注冊(cè),返回頁面。如果不存在則將密碼加密處理(md5或者哈希加密生成一段密文,然后輸入密碼拼接生成的密文存入數(shù)據(jù)庫更保險(xiǎn))
插入成功成功,返回登錄界面。
登錄:
和注冊(cè)一樣判斷用戶名。
提交到后臺(tái)
后臺(tái)可以用mysql_real_escape_string()函數(shù)對(duì)用戶名和密碼進(jìn)行轉(zhuǎn)義,防止sql注入
密碼同樣道理加密。去數(shù)據(jù)庫查詢用戶名和密碼,返回成功,則將用戶id號(hào)和用戶名存入session里。跳轉(zhuǎn)頁面。
reg.php文件
?php
header("Content-type:text/html;charset=utf-8");
if($_POST){
$dsn = 'mysql:dbname=1104javab;host=127.0.0.1';
$user = 'root';
$password = '';
try{
$pdo = new pdo($dsn,$user,$password,array(PDO::MYSQL_ATTR_INIT_COMMAND = 'SET NAMES \'UTF8\'')
);
}catch(Exception $e){
echo '錯(cuò)誤'.$e-getmessage();
}
$name = $_POST['name'];
$pwd = md5($_POST['pwd']);
$sql = "insert into 表 (username,password) values ('$name','$pwd')";
$exec = $pdo-query($sql);
if($exec){
echo "scriptalert('成功');location.href='reg.html'/script";
}else{
echo "scriptalert('失敗');location.href='reg.html'/script";
}
}
?
reg.html文件
form action='reg.php' method='post'
用戶名:input type='text' name='name'
密碼:input type='password' name='pwd'
input type='submit' value='submit'
/form
login.html文件
form action='reg.php' method='post'
用戶名:input type='text' name='name'
密碼:input type='password' name='pwd'
input type='submit' value='submit'
/form
login.php文件
header("Content-type:text/html;charset=utf-8");
if($_POST){
$dsn = 'mysql:dbname=1104javab;host=127.0.0.1';
$user = 'root';
$password = '';
try{
$pdo = new pdo($dsn,$user,$password,array(PDO::MYSQL_ATTR_INIT_COMMAND = 'SET NAMES \'UTF8\'')
);
}catch(Exception $e){
echo '錯(cuò)誤'.$e-getmessage();
}
$name = $_POST['name'];
$pwd = $_POST['pwd'];
$sql = "select user_id from 表名 where username='$name' and password='$pwd'";
$stmt = $pdo-query($sql);
$info = $stmt-fetch(PDO::FETCH_ASSOC);
if($info){
echo "登錄成功";
}else{
echo "登錄失敗";
}
}
大概這樣
登錄頁:login.php
?php
include("conn.php");
$username=$_POST['name'];
$password=$_POST['password'];
$yanzheng=$_POST['yanzheng'];
if(isset($_POST['submit']))
{
$sql=("select username,password from member where username='$username' and password='$password'") or die("sql語句執(zhí)行失敗");
//print_r($sql);
$ar=mysql_query($sql);
if($ar)
{
if($row=mysql_fetch_array($ar))
{
session_start();
if($_POST["yanzheng"])
{
if($yanzheng!=$_session[pic]||$yanzheng=="")
{
echo "驗(yàn)證碼輸入有誤";
exit;
}
if($yanzheng==$_session[pic])
{
header("location:index.php");
}
}
}
else
{
echo "用戶名或密碼錯(cuò)誤";
}
}
}
?
form action="login.php" method="post"
table border=1 align=center width=500 height=300 bgColor=#DFFFDF bordercolor=#fffbec
tr
td colspan=2 align=center用戶登錄/td
/tr
tr
td用戶姓名:/td
tdinput type="text" name="name" id="name"http://td
/tr
tr
td用戶密碼:/td
tdinput type="password" name="password" id="password"http://td
/tr
tr
td驗(yàn)證碼:/td
tdinput type="text" name="yanzheng" id="yanzheng"/
img src="yanzheng1.php" width="50" height="30"/img
/td
/tr
tr
td colspan=3 align=center
input type="submit" name="submit" value="登錄"/
input type="reset" name="reset" value="重置"/
a href="register.php"注冊(cè)/a
/td
/tr
/table
/form
注冊(cè)頁:register.php
?php
include("conn.php");
if(isset($_POST['submit'])$_POST['submit']) {
if($_POST['username']=='')
{
echo "用戶名不能為空";
exit();
}
if($_POST['password']=='')
{
echo "密碼不能為空";
exit();
}
if($_POST['realpass']!=$_POST['password'])
{
echo "兩次密碼輸入不一致";
exit();
}
$sql="insert into member(username,real_name,password,email,headimg) values('$_POST[username]','$_POST[username]','$_POST[password]','$_POST[email]','')";
$ar=mysql_query($sql);
if($ar)
{
header("location:index.php");
}
else
{
echo mysql_error();
}
}
?
body
form action="register.php" method="post"
table border=1 align=center width=500
tr
td height=40 bgColor=#DFFFDF colspan=2會(huì)員注冊(cè) [a href="login.php"返回登錄頁/a]/td
/tr
tr
td height=40 bgColor=#fffbec 會(huì)員ID/td
tdinput type="text" name="username" id="username"http://td
/tr
tr
td height=40 bgColor=#fffbec密碼/td
tdinput type="password" name="password" id="password"http://td
/tr
tr
td height=40 bgColor=#fffbec確認(rèn)密碼/td
td
input type="password" name="realpass" id="realpass"/
/td
/tr
tr
td height=40 bgColor=#fffbecEMAIL/td
tdinput type="text" name="email" id="email"/
/tr
tr
td height=40 bgColor=#fffbec/td
tdinput type="submit" name="submit" value="注冊(cè)"/input type="reset" value="重置"/td
/tr
/table
/form
/body
主頁顯示:index.php
?php
include("conn.php");
function cutstr($str,$cutleng)
{
$str = $str; //要截取的字符串
$cutleng = $cutleng; //要截取的長度
$strleng = strlen($str); //字符串長度
if($cutleng$strleng)return $str;//字符串長度小于規(guī)定字?jǐn)?shù)時(shí),返回字符串本身
$notchinanum = 0; //初始不是漢字的字符數(shù)
for($i=0;$i$cutleng;$i++)
{
if(ord(substr($str,$i,1))=128)
{
$notchinanum++;
}
}
if(($cutleng%2==1)($notchinanum%2==0)) //如果要截取奇數(shù)個(gè)字符,所要截取長度范圍內(nèi)的字符必須含奇數(shù)個(gè)非漢字,否則截取的長度加一
{
$cutleng++;
}
if(($cutleng%2==0)($notchinanum%2==1)) //如果要截取偶數(shù)個(gè)字符,所要截取長度范圍內(nèi)的字符必須含偶數(shù)個(gè)非漢字,否則截取的長度加一
{
$cutleng++;
}
return substr($str,0,$cutleng);
}
?
html
head
script type="text/javascript"
function All(e, itemName)
{
var aa = document.getElementsByName(itemName);
for (var i=0; iaa.length; i++)
aa[i].checked = e.checked; //得到那個(gè)總控的復(fù)選框的選中狀態(tài)
}
function Item(e, allName)
{
var all = document.getElementsByName(allName)[0];
if(!e.checked) all.checked = false;
else
{
var aa = document.getElementsByName(e.name);
for (var i=0; iaa.length; i++)
if(!aa[i].checked) return;
all.checked = true;
}
}
/script
/head
?php
include("conn.php");
if(isset($_POST['del']))
{
$mm = $_POST["selected"];
$id =implode(",",$mm);
$sql = "delete from forums where id in(".$id.")";
//echo $sql;
$result=mysql_query($sql);
echo $result?"刪除成功":"刪除失敗";
}
?
table style="BORDER-BOTTOM-WIDTH: 1px; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=600 align=center border=1 bordercolor=#ddddff
tr align=middle
td height=40 bgColor=#DFFFDF colspan=3論壇列表/td
/tr
tr
td colspan=3a href="login.php" style="float:right"[退出系統(tǒng)]/aa href="add_forum.php" style="float:right"[添加論壇]/a/td
td/td
/tr
tr align=middle
td height=40 bgColor=#DFFFDF width=80狀態(tài)/td
td height=40 bgColor=#DFFFDF論壇/td
td height=40 bgColor=#DFFFDF最后更新/td
/tr
?php
$sql="select * from forums";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
if($num0)
{
while($row=mysql_fetch_array($result)){
?
tr align=middle
td bgColor=#fffbecinput type="checkbox" name="selected" value="1"http://td
td height=50 bgColor=#fffbec width=300
?php
echo "diva href=\"forums.php?F=".$row['ID']."\"".$row['forum_name']."/a/div";
echo cutstr($row['forum_description'],24);//最多顯示24個(gè)字節(jié),12個(gè)字,多余部分用省略號(hào)代替
echo "……";
?
/td
td height=50 bgColor=#fffbecdiv?php echo $row['last_post_time']."by".$row['last_post_author']?/div/td
/tr
?php
}
}
else
{
echo "tr bgColor=#fffbectd colspan=3對(duì)不起,論壇尚在創(chuàng)建中……/td/tr";
}
?
tr
td colspan=3 input type="checkbox" name="selected" value="1" onclick="All(this,'selected')"/全選/不全選/td
/tr
tr
tdinput type="button" name="del" id="del" value="刪除選中項(xiàng)"/
?php
?
/td
/tr
/table
/html
數(shù)據(jù)庫你就自己建,望采納~