(菜鸟交流)简单注册系统实现

我的库名db_user  表名tbl_user

字段名有id username password sex。

<?php
$db=mysql_connect("localhost","root","");//连接数据库
mysql_select_db("db_user");
mysql_query("set names utf8");

//判断提交键是否存在
if(isset($_POST['tj'])){

//从表单获取值
 $userme=$_POST['username'];
 $password=$_POST['password'];

//确认密码
 $conpassword=$_POST['conpassword'];

//判断两次密码输入是否一样

if($password==$conpassword){

//向表中插入数据username、password(省略sex)
 $sql="insert into tbl_user(username,password) values('$username','$password')";
//执行sql语句   

$result=mysql_query($sql);
}
else{
 echo "<script>alert('两次密码输入不一致');</script>";
 }

if($result)
{
 echo "<script>alert('注册成功');</script>";
}
else
{
 echo "<script>alert('注册失败);</script>";
}
}
?>

//以下是注册界面,我用的<p></p>你也可以用<div></div>
<form method="post" action="#">
  <p>用户名:
  <input type="text" name="username" id="username">
  </p>
  <p>密码:
    <input type="password" name="password" id="password">
  <div class="item_desc">密码长度6~14位,字母区分大小写。</div>
  </p>
  <p>确认密码:
    <input type="password" name="conpassword" id="conpassword">
  </p>
   性别:
  <input name="sex" type="radio" value="1" checked="checked" />
  男  
  <input type="radio" name="sex" value="2" />
  女<br>
 
  <p>
    <input type="submit" name="tj" id="tj" value="注册">
    <input type="reset" value="重置">
  </p>
</form>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值