提示38,40,55,65 这4个错误,请问错误在哪里?如何改正
<?php //表单进行了提交处理 if(!empty($_POST['username'])) { include_once './lib/fun.php'; $username = trim($_POST['username']); $password = trim($_POST['password']); $repassword = trim($_POST['repassword']); if(!$username) { echo '用户名不能为空';exit; } if(!$password) { echo '密码不能为空';exit; } if(!$repassword) { echo '确认密码不能为空';exit; } if(!$password !== !$repassword) { echo '两次输入密码不一致';exit; } //数据库连接 $con = mysqlInit('127.0.0.1','root','star','imooc_mall'); if(!$con) { echo mysqli_errno();exit; } //判断用户是否在数据表存在 $sql = "SELECT COUNT( `id` ) as total FROM `im_user` WHERE `username` = '{$username}'"; $obj = mysqli_query($sql); $result = mysqli_fetch_assoc($obj); //验证用户名是否存在 if(isset($result['total']) && $result['total'] > 0) { echo '用户已经存在,请重新输入'; exit; } //密码加密处理 $$password=createPassword($password); unset($obj,$result,$sql); $sql = "INSERT `im_user`(`username`,`password`,`create_time`) vaules('{$username}','{$password}','{$_SERVER['REQUEST_TIME']}')"; $obj = mysqli_query($sql); if($obj) { $userId = mysqli_insert_id(); echo sprintf('恭喜注册成功,您的用户名是%s,用户id是%s',$username,$userId); exit; } else { echo mysqli_errno();exit; } } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>M-GALLARY|用户注册</title> <link type="text/css" rel="stylesheet" href="./static/css/common.css"> <link type="text/css" rel="stylesheet" href="./static/css/add.css"> <link rel="stylesheet" type="text/css" href="./static/css/login.css"> </head> <body> <div class="header"> <div class="logo f1"> <img src="./static/image/logo.png"> </div> <div class="auth fr"> <ul> <li><a href="login.php">登录</a></li> <li><a href="register.php">注册</a></li> </ul> </div> </div> <div class="content"> <div class="center"> <div class="center-login"> <div class="login-banner"> <a href="#"><img src="./static/image/login_banner.png" alt=""></a> </div> <div class="user-login"> <div class="user-box"> <div class="user-title"> <p>用户注册</p> </div> <form class="login-table" name="register" id="register-form" action="register.php" method="post"> <div class="login-left"> <label class="username">用户名</label> <input type="text" class="yhmiput" name="username" placeholder="Username" id="username"> </div> <div class="login-right"> <label class="passwd">密码</label> <input type="password" class="yhmiput" name="password" placeholder="Password" id="password"> </div> <div class="login-right"> <label class="passwd">确认</label> <input type="password" class="yhmiput" name="repassword" placeholder="Repassword" id="repassword"> </div> <div class="login-btn"> <button type="submit">注册</button> </div> </form> </div> </div> </div> </div> </div> <div class="footer"> <p><span>M-GALLARY</span> ©2017 POWERED BY IMOOC.INC</p> </div> </body> <script src="./static/js/jquery-1.10.2.min.js"></script> <script src="./static/js/layer/layer.js"></script> <script> $(function () { $('#register-form').submit(function () { var username = $('#username').val(), password = $('#password').val(), repassword = $('#repassword').val(); if (username == '' || username.length <= 0) { layer.tips('用户名不能为空', '#username', {time: 2000, tips: 2}); $('#username').focus(); return false; } if (password == '' || password.length <= 0) { layer.tips('密码不能为空', '#password', {time: 2000, tips: 2}); $('#password').focus(); return false; } if (repassword == '' || repassword.length <= 0 || (password != repassword)) { layer.tips('两次密码输入不一致', '#repassword', {time: 2000, tips: 2}); $('#repassword').focus(); return false; } return true; }) }) </script> </html>
0
收起
正在回答 回答被采纳积分+1
3回答
zhanhonglv
2018-11-29 17:54:09
<?php /** *数据库连接初始化 */ function mysqlInit($host,$username,$password,$dbName) { $con = mysqli_connect($host,$username,$password); if(!$con) { return false; } mysqli_select_db($con,$dbName); mysqli_set_charset($con,'utf8'); return $con; } function createPassword($password) { if(!$password) { return false; } return md5(md5($password).'IMOOC'); }
PHP小白零基础入门
- 参与学习 人
- 提交作业 626 份
- 解答问题 4930 个
想要学好Web后端开发的中流砥柱语言,本阶段为你轻松铺就扎实的基础,从前端网页布局的搭建到后台PHP开发,助你从零基础到掌握主流开发语言。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星