简体   繁体   English

密码保护 PHP 文件

[英]Password Protect PHP File

In PHP, how can I password protect my php file so I have to go to:在 PHP 中,我如何用密码保护我的 php 文件,所以我必须去:

http://www.example.com/upload.php/?pass=password http://www.example.com/upload.php/?pass=password

If you know how to do this I would greatly appreciate a snippet of code.如果您知道如何执行此操作,我将不胜感激一段代码。

我将引导您使用读取 url 路径的 $_GET,但请注意,这只是不安全的。

Alright.好吧。 I used this code.我使用了这个代码。 It's just for something small.这只是为了小事。

<?php
$pass = $_GET['pass'];
if(!isset($pass)) {
    exit(0);
} else {
    if($pass != 'examplepass') {
        exit(0);
    }
}
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM