• php+Mysql页面注册代码


    页面设置代码:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    </head>
    <body>
    <form action="register_post.php" method="post">
    <table>
    <tr>
    <td>用户名:</td>
    <td><input type="text" name="uname" placeholder="请输入账号"></td>
    </tr>
    <tr>
    <td>密码:</td>
    <td><input type="password" name="pwod" placeholder="请输入密码"></td>
    </tr>
    </table>
    <input type="submit" value="注册">
    </form>
    </body>
    </html>

    注册处理页面代码:
    <?php
    /**
    * Created by xx.
    * User: msi
    * Date: 2017/10/24
    * Time: 11:00
    */

    header("content-type:text/html; charset=utf-8");

    //引入前面的DBDA方法集文件
    require_once "../DBDA.class.php";
    $db = new DBDA();
    var_dump($_POST);
    if(!empty($_POST)) {
    $uname = $_POST["uname"];
    //查询用户注册的用户名是否和数据库已有的用户名重复,并返回查询结果;
    $sql = "select * from t_user WHERE uname = '{$uname}'";
    // echo $sql;
    $result = $db->strQuery($sql);

    //}
    if ($result != "0") {
    exit("用户名字被占用");
    } else {
    $sql_insert = "insert into t_user(uname,pwod) VALUES ('{$_POST["uname"]}','{$_POST["pwod"]}')";
    echo $sql_insert;
    $result2 = $db->Query($sql_insert, 0);
    var_dump($result2);
    }
    }
    //echo "张三";
    //echo $_POST['uname'];
    //echo $_POST['pwod'];
    ?>

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    </head>
    <body>

    </body>
    </html>
    这样就完成啦!
  • 相关阅读:
    win10重装vscode后打不开
    GDB 调试
    分布式架构--概述一
    汇编语言答案(王爽)第三版
    matplotlib之热成像图
    matplotlib之等高线图
    matplotlib之饼状图
    matplotlib之条形图绘制
    360图片网站批量抓取
    数据转换
  • 原文地址:https://www.cnblogs.com/GP1014336455/p/7738553.html
Copyright © 2020-2023  润新知