u_signup.htmhtml
成都创新互联专业为企业提供无棣网站建设、无棣做网站、无棣网站设计、无棣网站制作等企业网站建设、网页设计与制作、无棣企业网站模板建站服务,10多年无棣做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
head
/head
title欢迎注册网络图书销售信息管理系统/title
body
p align="center" class="style"会员注册/p
hr
form name="form1" method="post" action="u_signup.php"
p align="center"身份证号input name="u_sfzh" type="text" maxlength="18"/p
p align="center"会员姓名input name="u_hyxm" type="text" /p
p align="center"会员密码input name="u_hymm1" type="password" /p
p align="center"密码确认input name="u_hymm2" type="password" /p
p align="center"联系电话input name="u_lxdh" type="text" /p
p align="center"联系地址input name="u_lxdz" type="text" /p
p align="center"银行名称input name="u_yhmc" type="text" /p
p align="center"银行卡号input name="u_yhkh" type="text" /pp align="center"input name="u_return" type="submit" value="会员注册"/p
/form
/body
/html u_signup.php?php
//验证身份证号
$sfzh=$_POST['u_sfzh'];
if(empty($sfzh))
die("身份证号不能为空");
else if(strlen($sfzh)!=18)
die("身份证号应为18位");
else if(!is_numeric($sfzh))
die("身份证号应为18位数字");//验证会员姓名
$hyxm=$_POST['u_hyxm'];
if(empty($hyxm))
die("会员姓名不能为空");
else if(strlen($hyxm)4)
die("会员姓名应最少2个字符");
//验证会员密码
$hymm1=$_POST['u_hymm1'];
$hymm2=$_POST['u_hymm2'];
if(empty($hymm1) or empty($hymm2))
die("会员密码不能为空");
else if(strlen($hymm1)4 or strlen($hymm2)4 )
die("会员密码至少是4个字符");
else if($hymm1!=$hymm2)
die("两次输入的密码不一致");//验证联系电话
$lxdh=$_POST['u_lxdh'];
if(empty($lxdh))
die("联系电话不能为空");
else if(!is_numeric($lxdh))
die("联系电话应为数字");//验证联系地址
$lxdz=$_POST['u_lxdz'];
if(empty($lxdz))
die("联系地址不能为空");
else if(strlen($lxdz)6)
die("联系地址应最少6个字符");//验证银行名称和银行卡号
$yhmc=$_POST['u_yhmc'];
$yhkh=$_POST['u_yhkh'];
if(empty($yhmc) or empty($yhkh))
die("银行名称和银行卡号不能为空");
else if(strlen($yhmc)4 or strlen($yhkh)4 )
die("银行名称和银行卡号至少是4个字符");//获取系统日期和时间
$v_time=date("Y-m-d H:i:s");include "conn.php";mysql_query("set names 'GB2312'");//判断是否存在相同用户
//查询数据的sql语句形式:select * from member where 身份证号='123456789012345678'
$v_find="select * from member where 身份证号='".$sfzh."'";
//echo($v_find);
//echo("br");
$result=mysql_query($v_find,$conn);
$record=mysql_num_rows($result);
if($record0)
die($sfzh."该会员身份证号已经注册,不得重复,注册失败。");//注册用户
//插入数据的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("注册成功");?conn.php?php
$host="localhost";
$user="root";
$password="123456";$conn=mysql_connect($host,$user,$password);
if(!$conn)
die("连接MySQL服务器失败。".mysql_error());$dbase="bookstore";
$db_select=mysql_select_db($dbase,$conn);
if(!$db_select)
die("连接MySQL数据库失败。".mysql_error());
?
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 '错误'.$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 '错误'.$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 "登录失败";
}
}
大概这样
有两处错误
$sql = "insert into users(user,pass) values('$user','$pass')";改为
$sql = "insert into users(user,pass) values(".$user.",".$pass.")";
$user $pass 没有赋值操作,应该是为空,给它赋值一下应该就可以了