To understand PHP's header()

前端 未结 3 1692
南笙
南笙 2020-12-19 16:53

Where do you use the command header()?

I have the following code at handlers/handle_login.php. The user has gone to the site from index.php

3条回答
  •  离开以前
    2020-12-19 17:16

    Set the location to the complete URL of the index.php, not just the filename. According to php.net, this is the right way to do it, don't use relative paths. Here is an example:

     if(!$logged_in){
         header("Location: http://exampledomain.com/index.php");
         die("You are not logged_in");
     }
    

提交回复
热议问题