Results 1 to 7 of 7

Thread: [Resolved] Unwanted elimination of zero in POST value

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    121

    Resolved [Resolved] Unwanted elimination of zero in POST value

    Hello all.
    I have a form page with a field for Zip Codes:
    Code:
    <input type="text" name="customer_zip">
    Now, some Zip Codes, in New Jersey in particular, begin with a zero. As in 01234.
    When this field gets posted, the zero in the front gets trimmed.
    I don't know if it's the operating system (Win 2k Server) or PHP.
    Does anyone know how I can rectify this situation?
    Many thanks.
    Last edited by solitario; Sep 8th, 2005 at 11:41 AM.

  2. #2
    Hyperactive Member ninjanutz's Avatar
    Join Date
    Jun 2005
    Location
    Bayside
    Posts
    256

    Re: Unwanted elimination of zero in POST value

    i think its thge operating system cause wenever i wanna trim something i gotta use the trim(); function

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

    Re: Unwanted elimination of zero in POST value

    could i see an example of how you are using it?.... cuz it sounds kinda funky to me.
    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.

  4. #4
    Hyperactive Member ninjanutz's Avatar
    Join Date
    Jun 2005
    Location
    Bayside
    Posts
    256

    Re: Unwanted elimination of zero in POST value

    who? me or him

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

    Re: Unwanted elimination of zero in POST value

    him.
    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.

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

    Re: Unwanted elimination of zero in POST value

    Quote Originally Posted by solitario
    Hello all.
    I have a form page with a field for Zip Codes:
    Code:
    <input type="text" name="customer_zip">
    Now, some Zip Codes, in New Jersey in particular, begin with a zero. As in 01234.
    When this field gets posted, the zero in the front gets trimmed.
    I don't know if it's the operating system (Win 2k Server) or PHP.
    Does anyone know how I can rectify this situation?
    Many thanks.
    All post variables should be sent to the PHP script as strings. So unless an operation in your script has cast the data type of the variable to a numeric type, the zero should remain.

    To force a string type when carrying out operations on the variable you should explicitly cast it each time:
    Code:
    $customer_zip = (string) $_POST['customer_zip'];
    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
    Lively Member
    Join Date
    Jul 2004
    Posts
    121

    Re: Unwanted elimination of zero in POST value

    That did it, visualAd. Thanks.

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