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
}
精彩评论