Results 1 to 6 of 6

Thread: Post only

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    Osaka
    Posts
    200

    Post only

    How to enforce that visitor is not using query string to access the page instead using post method only.
    I don't want visitor should go thru GET method.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Post only

    All variables from the query string are loaded into the $_GET array and all variables from the HTTP body in a POST request are loaded into $_POST. If you want to ensure that your users are using a post request, use the $_POST array.
    PHP Code:
    $var $_POST['form_var_name']; 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    Junior Member
    Join Date
    Mar 2006
    Location
    Newcastle, UK
    Posts
    19

    Re: Post only

    This is a bit of code i wrote so if the users uses a GET request then it writes their IP to a text file!

    PHP Code:
    <?php 
    $ipbanfile 
    "/home/site/public_html/Ipban.ban"#IP Ban File

    if($_SERVER['REQUEST_METHOD'] == "GET"){
    $fp fopen($ipbanfile"a+");
    fwrite ($fp"{$_SERVER['REMOTE_ADDR']}");
    fclose($fp);
    die(
    "So close... yet so far.");
    }
    ?>
    Last edited by Winsocket; Mar 9th, 2006 at 07:33 PM.

  4. #4
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    Re: Post only

    i see an error already...
    PHP Code:
    fwrite ($fp"$_SERVER['REMOTE_ADDR']");

    should be 

    fwrite 
    ($fp"$_SERVER[REMOTE_ADDR]");
    or
    fwrite ($fp$_SERVER['REMOTE_ADDR']); 
    Without balance, there could only be chaos.
    Without chaos, there could be no balance.
    I live with karma. Eat with destiny. Dream of life without shackles....
    Yet. If life had no consequences, life could not exist, nor could it flourish.


    If at first you dont succeed.You're screwed.

    C++/Java NOOB.

    I aint a professional at PHP, but if i can help i will.

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Post only

    Code:
    fwrite ($fp, "$_SERVER[REMOTE_ADDR]");
    You shouldn't use that either, you have not included REMOTE_ADDR in quotes. This would be correct:

    "{$_SERVER['REMOTE_ADDR']}"
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6
    Junior Member
    Join Date
    Mar 2006
    Location
    Newcastle, UK
    Posts
    19

    Re: Post only

    Yeah, edited it, sorry i wrote that from memory. Simple mistake I also didn't need the extra die(); and exit(); so edited that as well. so...
    PHP Code:
    <?php 
    $ipbanfile 
    "/home/site/public_html/Ipban.ban"#IP Ban File 

    if($_SERVER['REQUEST_METHOD'] == "GET"){ 
    $fp fopen($ipbanfile"a+"); 
    fwrite ($fp"{$_SERVER['REMOTE_ADDR']}"); 
    fclose($fp); 
    die(
    "Please do not use the GET method!"); 

    ?>
    Last edited by Winsocket; Mar 9th, 2006 at 07:35 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width