php学生信息管理(三)注册页设计

注册页前端

文件名:E:\phpstudy_pro\WWW\xsxxgl\zhuce.php

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/comm.css">
    <link rel="stylesheet" href="css/zhuce.css">
</head>

<body>

    <h1>学生信息管理系统</h1>
    <hr>
    <div class="da">
        <form action="zhucechuli.php" method="post">

            <div class="hang">
                <div class="zuo">用户名</div>
                <div class="you"><input type="text" name="yhm" id="" class="wbk"></div>
            </div>
            <div class="hang">
                <div class="zuo">密&nbsp;&nbsp;&nbsp;码</div>
                <div class="you"><input type="password" name="mm" id="" class="wbk"></div>
            </div>
            <div class="hang">
                <div class="zuo"> </div>
                <div class="you"> <input type="submit" value="注册" class="zc"></div>
            </div>

        </form>
    </div>
</body>

</html>

注册页css文件 E:\phpstudy_pro\WWW\xsxxgl\css\zhuce.css

.da {

    width: 350px;

    margin: 100px auto;

    background-color: #bee4a8;

    padding: 20px;

}

.zc {

    border: 1px solid black;

    display: inline-block;

    width: 60px;

    height: 30px;

    background-color: #7f945d;

    text-align: center;

    font-size: 20px;

    box-sizing: border-box;

    line-height: 30px;

    margin-left: 150px;

    border-radius: 3px;

    cursor: pointer;

}

.zuo,

.you {

    float: left;

}

.zuo {

    width: 60px;

    height: 50px;

    font-size: 18px;

}

.hang {

    height: 50px;

    line-height: 50px;

}

.wbk {

    height: 35px;

    width: 220px;

    font-size: 16px;

    padding-left: 20px;

    border-radius: 5px;

}
 

h1 {

    text-align: center;

    margin-top: 50px;

    font-weight: 500;

}

hr {

    height: 2px;

    background-color: #a9d311;

}

注册页后端

文件名:E:\phpstudy_pro\WWW\xsxxgl\zhucechuli.php

<?php

$yhm=$_POST['yhm'];

$mm=$_POST['mm'];

// echo $yhm,$mm;

// if用户名不存在,将注册的用户名密码写入数据库

$sql="select count(*) from yhb where yhm='{$yhm}'";

$pdo=new PDO('mysql:dbname=mydb;host=localhost','root','123456');

// $n=$pdo->query($sql)->fetchAll()[0][0];

$jieguo=$pdo->query($sql);

$arr=$jieguo->fetchAll();

$n=$arr[0][0];

echo $n;

if ($n==0) {

    //可以注册,注册成功,返回登录页

    $sql="insert into yhb values(null,'{$yhm}','{$mm}')";

    $m=$pdo->exec($sql);

    if($m==1){

        echo "<script>alert('注册成功!');location='denglu.html';</script>";

    }else{

        echo "<script>alert('注册失败!');location='zhuce.php';</script>";

    }

}else{

    //用户名已经存在,不能注册,返回注册页

    echo "<script>alert('用户名已经存在!');location='zhuce.php';</script>";

}

  • 22
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值