dongpao9437 2012-10-23 15:15
浏览 81
已采纳

我刚刚启动PHP,我想知道如何修复此解析错误。 这是错误:[关闭]

Parse error: parse error in C:\wamp\www\Discussion Forums\login.php on line 70

Here is my code. By the way, I'm making a login page which has functions config (for database connectivity), header and footer page , and I use WampServer and Dreamweaver.

<?php
session_start();
require("config.php");
require("functions.php");
$db = mysql_connect($dbhost, $dbuser, $dbpassword);
mysql_select_db($dbdatabase, $db);
$db = mysql_connect($dbhost, $dbuser, $dbpassword);
mysql_select_db($dbdatabase, $db);
if($_POST['submit']) 
{
    $sql = "SELECT * FROM users WHERE username = '"
    . $_POST['username'] . "' AND password = '"
    . $_POST['password'] . "';";
    $result = mysql_query($sql);
    $numrows = mysql_num_rows($result);
    $result = mysql_query($sql);
    $numrows = mysql_num_rows($result);
    if($numrows == 1) 
        {
            $row = mysql_fetch_assoc($result);
            if($row['active'] == 1) 
                {
                    session_register("USERNAME");
                    session_register("USERID");
                    switch($_GET['ref']) 
                    {
                        case "newpost":
                        if(isset($_GET['id']) == FALSE) 
                            {
                                header("Location: " . $config_basedir .
                                "/newtopic.php");
                            }
                        else 
                            {
                                header("Location: " . $config_basedir .
                                "/newtopic.php?id=" . $_GET['id']);
                            }
                        break;
                        case "reply":
                        if(isset($_GET['id']) == FALSE) 
                            {
                                header("Location: " . $config_basedir .
                                "/newtopic.php");
                            }
                        else 
                            {
                                header("Location: " . $config_basedir .
                                "/newtopic.php?id=" . $_GET['id']);
                            }
                        break;
                        default:
                        header("Location: " . $config_basedir);
                        break;
                    }
                }
                else {
                require("header.php");
                echo "This account is not verified yet. You were emailed a link
                to verify the account. Please  click on the link in the email to
                                                        continue.";
                }
            echo "This account is not verified yet. You were emailed a link
          to verify the account. Please click on the link in the email to
          continue.";
        }
}
else {
header("Location: " . $config_basedir . "/login.php?error=1");
}
else {
require("header.php");
if($_GET['error']) {
echo "Incorrect login, please try again!";
}
}
?>
<form action="<?php echo pf_script_with_get($SCRIPT_NAME); ?>"
  method="post">
<table>
    <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></td>
        <td><input type="submit" name="submit" value="Login!"></td>
    </tr>
</table>
</form>
Don't have an account? Go and <a href="register.php">Register</a>!

<?php
 }
  require("footer.php");
?>
  • 写回答

3条回答 默认 最新

  • dtfo55908 2012-10-23 15:37
    关注

    On line number 67 use else if($somecondition) instead because in if-elseif-else can have only one else block. Also there is errors in your logic I am putting the new code it may help you.

          <?php
    session_start();
    require("config.php");
    require("functions.php");
    $db = mysql_connect($dbhost, $dbuser, $dbpassword);
    mysql_select_db($dbdatabase, $db);
    $db = mysql_connect($dbhost, $dbuser, $dbpassword);
    mysql_select_db($dbdatabase, $db);
    if($_POST['submit']) 
    {
        $sql = "SELECT * FROM users WHERE username = '"
        . $_POST['username'] . "' AND password = '"
        . $_POST['password'] . "';";
        $result = mysql_query($sql);
        $numrows = mysql_num_rows($result);
        $result = mysql_query($sql);
        $numrows = mysql_num_rows($result);
        if($numrows == 1) 
            {
                $row = mysql_fetch_assoc($result);
                if($row['active'] == 1) 
                    {
                        session_register("USERNAME");
                        session_register("USERID");
                        switch($_GET['ref']) 
                        {
                            case "newpost":
                            if(isset($_GET['id']) == FALSE) 
                                {
                                    header("Location: " . $config_basedir .
                                    "/newtopic.php");exit;
                                }
                            else 
                                {
                                    header("Location: " . $config_basedir .
                                    "/newtopic.php?id=" . $_GET['id']);exit;
                                }
                            break;
                            case "reply":
                            if(isset($_GET['id']) == FALSE) 
                                {
                                    header("Location: " . $config_basedir .
                                    "/newtopic.php");exit;
                                }
                            else 
                                {
                                    header("Location: " . $config_basedir .
                                    "/newtopic.php?id=" . $_GET['id']);exit;
                                }
                            break;
                            default:
                            header("Location: " . $config_basedir);
                            break;
                        }
                    }
                    else {
                        //require("header.php");
                            $msg = base64_encode("This account is not verified yet. You were emailed a link
                          to verify the account. Please click on the link in the email to
                          continue.");
                          header("Location: " . $config_basedir . "/login.php?msg=".$msg);exit;
                    }
                        $msg = base64_encode("This account is not verified yet. You were emailed a link
                      to verify the account. Please click on the link in the email to
                      continue.");
                      header("Location: " . $config_basedir . "/login.php?msg=".$msg);exit;
    
            }else{
                 $msg = base64_encode("You have incorrect username or password");
                      header("Location: " . $config_basedir . "/login.php?msg=".$msg);exit;
            }
    }
    
    require("header.php");
    if($_GET['msg']) {
        echo base64_decod($msg);
    }
    
    ?>
    <form action="<?php echo pf_script_with_get($SCRIPT_NAME); ?>"
      method="post">
    <table>
        <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></td>
            <td><input type="submit" name="submit" value="Login!"></td>
        </tr>
    </table>
    </form>
    Don't have an account? Go and <a href="register.php">Register</a>!
    
    <?php
    
      require("footer.php");
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP