Jump to content

ISSET $_GET NOT WORKING


Gayner

Recommended Posts

because isset() checks to see if that variable is set.

 

So, if $_GET['God'] is set, then isset($_GET['God']) will translate to "true" but it won't give you the value of $_GET['God']

 

if you want to check to make sure $_GET['God'] is not only set, but set to something specific, use:

if ($isset($_GET['God']) && $_GET['God'] == "Enter")

 

so it checks to see if $_GET['God'] is set at all, and if it is (only if it is) it will then check the value.

because isset() checks to see if that variable is set.

 

So, if $_GET['God'] is set, then isset($_GET['God']) will translate to "true" but it won't give you the value of $_GET['God']

 

if you want to check to make sure $_GET['God'] is not only set, but set to something specific, use:

if ($isset($_GET['God']) && $_GET['God'] == "Enter")

 

so it checks to see if $_GET['God'] is set at all, and if it is (only if it is) it will then check the value.

 

 

oh, lol

 

ok thanks so i'll add the &&

 

wat about a | will that work too ?

Gayner something else you do to make sure that $god is  set before calling it. Welcome to the wonderful ternary operator.

 

<?php
// make $god equal $_GET['god'] if its set else make it empty ""
  $god = isset($_GET['god']) === true ? $_GET['god'] : "";
// you could add some filtering right there also
// $god = isset($_GET['god']) === true ? mysql_real_escape_string(strip_tags($_GET['god'])) : "";

  if($god == "Enter"){

   // stuff

  }

 

Gayner something else you do to make sure that $god is  set before calling it. Welcome to the wonderful ternary operator.

 

<?php
// make $god equal $_GET['god'] if its set else make it empty ""
  $god = isset($_GET['god'] === true ? $_GET['god'] : "";
// you could add some filtering right there also
// $god = isset($_GET['god'] === true ? mysql_real_escape_string(strip_tags($_GET['god'])) : "";

  if($god == "Enter"){

   // stuff

  }

 

Thanks so much code for such little code i want to do, but i guess that's php, i love the terny operator tho thx

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.