If url variable is empty redirect to home page

后端 未结 2 1024
予麋鹿
予麋鹿 2021-01-27 09:32

I am not able to get this to work correctly!!

I have a view.php page that uses a variable of \'ID\' to retrieve db info.

So my url is like this:

         


        
相关标签:
2条回答
  • 2021-01-27 09:49

    Try using empty():

    if(empty($_GET['id'])) 
    { 
      header('Location: /');
      exit; 
    }
    
    0 讨论(0)
  • 2021-01-27 09:52

    Another way:

    if(strlen($_GET['id'])>0) { 
     header('Location: /');
     exit; 
    }
    
    0 讨论(0)
提交回复
热议问题