Here is my code:

<files contacts.html>
order allow,deny
deny from all
Allow from access.php
</files>

I do not want contacts.html DIRECTLY accessed from the URL. I have a form on the index.html page that has a form with the action access.php. Once it confirms, it redirects it to contacts.html using the header function.

有帮助吗?

解决方案

You will want to use $_SESSION,

On access.php

session_start();

// some code here to authenticate

$_SESSION['hasAccess'] = true;

// redirect

Change contacts.html to contacts.php and at the top of this page

session_start();

if($_SESSION['hasAccess'] !== true){

    header('Location: index.php');
    die;

}

// the rest of your code
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top