开发者

check if a page is accessed from address bar or from submitted form

开发者 https://www.devze.com 2023-03-08 03:32 出处:网络
Just like the question title, if I have 开发者_运维问答an update_process.php, how to check if people access it by typing it in the address bar or if they go through the page from submitted form?

Just like the question title, if I have 开发者_运维问答an update_process.php, how to check if people access it by typing it in the address bar or if they go through the page from submitted form?

So if they type it in the address bar, I'll redirect them to other pages.

Oh yeah, i'm talking about the method in CI. so maybe if the file is blog.php and method update_process, i don't want people to type in the address bar blog/update_process


You can check the $_SERVER global variable

$_SERVER['REQUEST_METHOD']

If not set to POST, then they did not use the form


if ( ! defined('BASEPATH')) exit('No direct access allowed');


You can use a hidden field inside your form and in your update_process.php check to see if this exists ($_POST['<field>'] or $_GET['<field>']).


if(isset($_POST['submit'])) //or GET
{
//form
}
else
{
//url
}
0

精彩评论

暂无评论...
验证码 换一张
取 消