HTML和嵌套的if语句

时间:2017-07-10 10:44:01

标签: php if-statement nested

我已将代码简化为基础知识,但我得到了相同的错误。

!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <?php if ('b'=='b') {
        if ('a'=='a'):?> 
             <a href="index_login.php">New Page</a>  
        <?php endif; ?>
    }     
</body>
</html>

1 个答案:

答案 0 :(得分:0)

试试这个

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {     
    if (!empty($_POST['LicenceNo']) && $_SESSION['MEMID'] == '')  {
        require ('sql_get_MNZID.php');                       
    }else { 
        if(isset($_SESSION['Password']) && isset($_POST['Password'])){                
            if ($_SESSION['Password'] == $_POST['Password']){
                echo '<a href="index_login.php">New Page</a>';    
            }  
        }
    }
}else{
    $_SESSION['MEMID'] = '';
    $_SESSION['Password'] = '';   
    $_SESSION['MemName'] = '';
}    
?>

**修改: - **然后重定向到另一个页面 替换这个

if ($_SESSION['Password'] == $_POST['Password']){
          echo '<a href="index_login.php">New Page</a>';    
} 

用这个

if ($_SESSION['Password'] == $_POST['Password']){
        echo '<script type="text/javascript">location.href = "index_login.php";</script>';  
} 

它适用于你。

这有效

if ($_SESSION['Password'] == $_POST['Password']){
    header("Location: mem_page.php");      
    exit;                        
}