php - how to tell $_GET parameters are equal to or not equal to -


i'm trying make dynamic page $_get vars(params) , have working if var equal something, display content. if var doesn't equal something, either displays content still, or doesn't display error; or displays error , content @ same time

<?php if(!isset($_get['type'])){     header("location: ?type=login"); } else {     $type = trim(strip_tags(stripslashes(mysql_real_escape_string($_get['type'])))); } if($type != 'login' || $type != 'register'){     ?>     <h1>what looking can't found!</h1>     <?php } if($type == 'login'){     ?>     <h1>login page:</h1>     <?php } if($type == 'register'){     ?>     <h1>register page:</h1>     <?php } 

?>

you have 2 problems in code:

  1. your check error needs use && , not ||. want see if login and register both not used.
  2. you need use if/else if statements make sure 1 condition ever present.

check code out:

<?php if(!isset($_get['type'])){     header("location: ?type=login"); } else {     $type = trim(strip_tags(stripslashes(mysql_real_escape_string($_get['type'])))); }  if($type != 'login' && $type != 'register'){     ?>     <h1>what looking can't found!</h1>     <?php } else if($type == 'login'){     ?>     <h1>login page:</h1>     <?php } else if($type == 'register'){     ?>     <h1>register page:</h1>     <?php } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -