Can I check post and get method at once

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    Can I check post and get method at once

    In my web page I want to check post and get method at once. This is my code. But this code is not working.."GET" recives data from ajax page and "POST" receives data from same php page.

    Code:
    if((isset($_GET['S'])==1) && (isset($_POST['Submit'])))
    echo "test";
    }
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    Yes you can
    PHP allow it very well

    Comment

    • yyuuvvii
      New Member
      • Feb 2010
      • 5

      #3
      Code:
      if((isset($_GET['S'])==1) or (isset($_POST['Submit'])))
      echo "test";
      }
      or you can also use
      Code:
      if((isset($_REQUEST['S'])==1) && (isset($_REQUEST['Submit'])))
      echo "test";
      }

      Comment

      • vijith vijayan
        New Member
        • Aug 2011
        • 5

        #4
        u r using ajax pages,hence there may be page refreshing issues,so i think you cant get the values properly,just echo 'S' and 'Submit' as

        Code:
        $ss=$_GET['S']);
        $su=$_POST['Submit']);
        
        echo $ss;//may be incorrect
        echo $su;//may be correct
        and find the error youself...also try with REQUEST[] hence more ajax pages deals with this...if not possible try with $_SESSION[] to data transfer and check as
        Code:
        if((isset($_SESSION['S'])==1)&&$SESSION['S']!=''))...
        after your codes,set
        Code:
         $_SESSION['S']='';
        its not a secure method...before 2 days i solve such kind of an issue like this

        Comment

        Working...