douxihui8270 2016-01-26 07:24
浏览 33
已采纳

PHP网站调试[重复]

This question already has an answer here:

I have a question, when cannot run this programme, it shows

Parse error: syntax error, unexpected 'username' (T_STRING) in C:\xampp\htdocs\fypp\index.php on line 9

<?php
    session_start();
    if (isset($_POST['bttLogin'])){
        require 'connect.php';
        $username = $_POST['username'];
        $password = $_POST['password'];
        $result = mysquli_query($con, 'select * from account where username="'.$username.'" and password="'.$password.'")
        if(mysqli_num_rows($result)==1) {
            $_SESSION['username'] = $username;
            header("Location: welcome.php");
        }
        else
            echo "account is invalid";
    }
    ?>
    <form method="post">
    <table cellpadding="2" cellspacing="2" border="1">
        <tr>
            <td>Username</td>
            <td><input type="text" name="username"></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input type="password"" name="password"></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="bttLogin" value="Login"></td>
        </tr>

thanks for answering :)

</div>
  • 写回答

2条回答 默认 最新

  • douhuzhi0907 2016-01-26 07:30
    关注

    First of all, paste your code correctly... You are missing </table> and </form> in the end...

    Second of all, you were missing a simple apostrophe and a semi-colon in the line

    $result = mysquli_query($con, 'select * from account where username="'.$username.'" and password="'.$password.'")

    Also, you should use mysqli_query instead of mysqlui_query... Typo!

    Your code should be as follows :

    <?php
    session_start();
    if (isset($_POST['bttLogin'])){
        require 'connect.php';
        $username = $_POST['username'];
        $password = $_POST['password'];
        $result = mysqli_query($con, 'select * from account where username="'.$username.'" and password="'.$password.'"');
        if(mysqli_num_rows($result)==1) {
            $_SESSION['username'] = $username;
            header("Location: welcome.php");
        }
        else
            echo "account is invalid";
    }
    ?>
    
    <form method="post">
    <table cellpadding="2" cellspacing="2" border="1">
        <tr>
            <td>Username</td>
            <td><input type="text" name="username"></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input type="password"" name="password"></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="bttLogin" value="Login"></td>
        </tr>
    </table>
    </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度