mysql与php实现注册页面及数据记录

html:

<body>
    <div class="register">
        <h1>注册成为新用户</h1>
        <form action="register.php" method="POST">
            <h4>基本信息:</h4>
            <label for="username">用户名:</label>
            <input type="text" name="username">
            <br>
            <label for="password">密码:</label>
            <input type="text" name="password">
            <br>
            <label for="email">邮箱:</label>
            <input type="text" name="email">
            <br>

            <h4>联系方式:</h4>
            <label for="qq">QQ:</label>
            <input type="text" name="qq">
            <br>
            <label for="phone">手机号码:</label>
            <input type="text" name="phone">
            <br>
            <label for="city">所在城市:</label>
            <input type="text" name="city">
            <br>
            <br>
            <br>
            <button type="submit" name="submit">注册</button>
    </div>
    </form>    
</body>

css:


        html{
            position: relative;
            line-height: 30px;
            background: rgba(173, 216, 230, 0.5);
        }
        input{
            border-radius: 20px;
            border: 1px solid lightblue;
        }
        .register{
            position: absolute;
            width:500px;
            margin-left: -250px;
            padding: 50px;
            left: 50%;
            border-radius: 30px;
        }
        .register h1{
            text-align: center;
            color: rgb(238, 65, 12)
        }
        label{
            display: inline-block;
            width: 180px;
            text-align: center;
        }
        button{
            height: 40px;width: 150px;
            border: none;
            background: rgba(240, 128, 128, 0.6);
            font-size: 20px;
            font-weight: bold;
            margin-left: 130px;
        }

php:

    <?php
    $username=$_POST['username'];
    $password=$_POST['password'];
    $email=$_POST['email'];
    $qq=$_POST['qq'];
    $phone=$_POST['phone'];
    $city=$_POST['city'];
    
    $dbc=mysqli_connect('127.0.0.1','root','','register') or die('连接数据库错误!');
    $query="INSERT INTO user_information VALUES('$username','$password','$email','$qq','$phone','$city')";
    $result=mysqli_query($dbc,$query) or die('数据请求失败!');
    mysqli_close($dbc);

    echo '<script>
    alert("您已注册成功!请返回并登录");
    window.location.href="#";
    </script>';
    ?>

此外还涉及sql数据库中新建表时列的设置,对于不同的列需要对应不同的排序规则和类型,暂不熟悉,后续用到再补充。此外还有sql内数据的编号、删除功能未学习。

 

此为学完第一二章,初步了解php和sql数据库使用的总结。

 

写完此文后发现的高级完整版,本文后续有需要会按此完善。

https://blog.csdn.net/qq_35661627/article/details/78564319

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值