求助求助求助

求助求助求助

<?php
 if(!empty($_POST['username'])){
    include_once './lib/fun.php';
        $username=trim($_POST['username']);
        $password=trim($_POST['password']);
        $repassword=trim($_POST['repassword']);
        $user_time=time();
        if(!$username){
            echo "用户名不能为空";
            exit;
        }
        if(!$password){
            echo "密码不能为空";
            exit;
        }
        if(!$repassword){
            echo "确认密码不能为空";
            exit;
        }
        if($password !==$repassword){
            echo "两次输入密码不一致,请重新输入";
            exit;
        }
        //数据库链接
        $conn=mysqlInit("localhost","root","","imooc_mall");
       // print_r($conn);
        if(!$conn)
        {
            echo mysql_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="login" id="login-form" action="login.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-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 () {
        $('#login-form').submit(function () {
            var username = $('#username').val(),
                password = $('#password').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;
            }


            return true;
        })

    })
</script>
</html>

请问这是哪里的问题啊 浏览器出错的是 parse error: syntax error, unexpected end of file in G:\wamp64\www\mall\login.php on line 117

没有发现问题

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

3回答
guly 2017-08-07 10:29:39

你好,代码的错误原因是因为php程序书写不规范,php代码中if判断无结束符号,代码如下:

<?php
 if(!empty($_POST['username'])){
    include_once './lib/fun.php';
        $username=trim($_POST['username']);
        $password=trim($_POST['password']);
        $repassword=trim($_POST['repassword']);
        $user_time=time();
        if(!$username){
            echo "用户名不能为空";
            exit;
        }
        if(!$password){
            echo "密码不能为空";
            exit;
        }
        if(!$repassword){
            echo "确认密码不能为空";
            exit;
        }
        if($password !==$repassword){
            echo "两次输入密码不一致,请重新输入";
            exit;
        }
        //数据库链接
        $conn=mysqlInit("localhost","root","","imooc_mall");
       // print_r($conn);
        if(!$conn)
        {
            echo mysql_errno();
            exit; 
        }
 
 }
?>

如果解决了您的问题请采纳,祝学习愉快!

  • 提问者 Joper #1
    是规范的 只是表我用了单引号应该用tab键上面那个
    2017-08-07 21:59:08
  • 好帮手慕查理 回复 提问者 Joper #2
    您好,是您最外层的 if(!empty($_POST['username'])){ } 判断少了最后的 } ,导致程序运行出错。祝学习愉快!
    2017-08-08 10:52:39
提问者 Joper 2017-08-06 16:18:46

助教帮忙!!!


提问者 Joper 2017-08-06 10:54:15

求解求解求解

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师