PHP kodu düzgün çalışmıyor

0 Cevap php
<?php
(E_ALL & ~E_NOTICE);
session_start();

// is the one accessing this page logged in or not?

if (!isset($_SESSION['db_is_logged_in']) || $_SESSION['db_is_logged_in'] !== true) {

    // not logged in, move to login page

    header('Location: login.php');
    exit;
}
else {
    echo "Welcome To The Test Page:";
    echo $_SESSION['logname'];
}

if (isset($_POST['submit'])) {
    test();
}

function test()
{
    $var = rand(1, 5);
    header("Location:{$var}.html");
    exit;
} 

<html>
    <body>
        <form action="<?=$_SERVER['PHP_SELF'];?>"  method="post">
            <input type="submit" name="submit" value="Take Test">
        </form>
    </body>
</html>

When the "take test " button is clicked i need 1 of the 5 html pages i.e (Question papers in this case ) to be displayed to the user. for that i have created the random number from 1 to 5. The pages have been names 1.html , 2.html and so on...

Herkes bu kod hata ayıklama misiniz?

0 Cevap