Results 1 to 8 of 8

Thread: Re: PHP Forms

  1. #1

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459

    Re: PHP Forms

    Hello!

    I am still using this $email = $HTTP_POST_VARS['email']; to get my forms or should i use $_POST['age']; ? Please suggest ...am i at any security risk by using that one ?

    Thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I think $HTTP_POST_VARS and $_POST are probably just as secure as one another. $HTTP_POST_VARS is deprecated, however, and it is also not an autoglobal.

    So a plus side is that you never have to do:

    Code:
    global $HTTP_POST_VARS;
    Inside a function.

    But security-wise, I think they're probably about the same.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Hi!

    I don't understand what do you mean by the global thing ? Is it good or bad ? Also i am using cookies to store information in my login form.

    Is there any way to detect weather cookies are enabled or not ?

    Thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    When you use $HTTP_POST_VARS, if you want to access it within a function, you'll have to do this:

    Code:
    function MyFunction() {
        global $HTTP_POST_VARS;
    
        echo $HTTP_POST_VARS['name'];
    }
    With $_POST, you can just do:

    Code:
    function MyFunction() {
        echo $_POST['name'];
    }
    As for detecting whether or not cookies are enabled, that's not possible. That's a browser setting, and PHP is a server side language, so it'll have no way of knowing.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Hello!

    But i have seen many website which says " That cookies are not enabled so please enable cookies to login" how they do it ?

    Thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    You just need to set a flag through the query string to indicate that you have attempted to set the cookie.

    If the browser did not fulfill the request then its value will not be present in the $_COOKIE array:
    PHP Code:
    <?php
    if (! isset ($_GET['cookieset'])) {
        
    setcookie ("testcookie""testvalue");
        echo (
    '<a href="?cookieset">click here to continue</a>');
    } else {
        if (isset (
    $_COOKIE['testcookie']))
            echo (
    $_COOKIE['testcookie']);
        else    
            echo (
    'i could not give you a cookie');
    }
    ?>
    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.

  7. #7

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Thanks visualAd and The Hobo.
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  8. #8
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by visualAd
    You just need to set a flag through the query string to indicate that you have attempted to set the cookie.

    If the browser did not fulfill the request then its value will not be present in the $_COOKIE array:
    PHP Code:
    <?php
    if (! isset ($_GET['cookieset'])) {
        
    setcookie ("testcookie""testvalue");
        echo (
    '<a href="?cookieset">click here to continue</a>');
    } else {
        if (isset (
    $_COOKIE['testcookie']))
            echo (
    $_COOKIE['testcookie']);
        else    
            echo (
    'i could not give you a cookie');
    }
    ?>
    Good call. I didn't think of that.
    My evil laugh has a squeak in it.

    kristopherwilson.com

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