How to write false $_REQUEST, please help

3 replies
This is if statement $_REQUEST if the language translated

if ($_REQUEST['language']) {
}

i need to set the opposite, if the language not translated, what its looks like, please help





which one is correct? or no one of them

if (!$_REQUEST['language']) {
}

if ($_REQUEST!['language']) {
}

if !($_REQUEST['language']) {
}
#$request #false #write
  • Profile picture of the author Vanfenix
    if (!$_REQUEST['language']) {
    }

    That is the correct one!

    The HTML selection list has no value attribute, to select a value javascript is used. Here a check is necessary to make sure that the language parameter is not blank. Also the single quotes around the request parameter are required as the language values are text, no single quotes are necessary for numeric values.


    As such - I recommend you use this. If this is similar to what you're after.

    <?if($_REQUEST['language']!=''){?>
    document.form1.language.value='<?=$_REQUEST['language']?>';
    <? } ?>
    Signature

    If you need a website, something cool, slick, and affordable - something with built in aweber, hosting included, extremely easy to use. Unlimited pages, Drag and drop functionality. E-mail me. vanfenix1 at gmail.com. || I'll set you up a site for 15 days to test out || Squeeze pages? no problem. Lightweight E-commerce? easy as pie. My Websites are not like you've ever seen. Try it today FREE!

    {{ DiscussionBoard.errors[3656072].message }}
  • Profile picture of the author msaqib301
    [DELETED]
    {{ DiscussionBoard.errors[3658455].message }}
    • Profile picture of the author phpbbxpert
      Originally Posted by msaqib301 View Post

      from my point of view 2nd one is correct.
      That should output errors.

      Do not use the code Vanfenix posted.
      Like MoneyMouse said, it is prone to XSS and other potential vulnerabilities.

      But I would extend the security further and use an array of except-able values.
      First clean it with trim and strip_tags like he showed.

      Then

      eg $lang_array = array('English', 'Dutch', 'German', 'etc');

      Then do a check to see it the $_REQUEST is in the array

      if(in_array($_REQUEST['language'], $lang_array)
      {
      //Your code
      }

      This way the code prone will only be run if the value is in your array.
      {{ DiscussionBoard.errors[3658804].message }}

Trending Topics