|
-
Sep 7th, 2005, 10:43 AM
#1
Thread Starter
Lively Member
[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.
-
Sep 7th, 2005, 12:10 PM
#2
Hyperactive Member
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
-
Sep 7th, 2005, 05:29 PM
#3
Hyperactive Member
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.
-
Sep 7th, 2005, 07:45 PM
#4
Hyperactive Member
Re: Unwanted elimination of zero in POST value
-
Sep 7th, 2005, 08:20 PM
#5
Hyperactive Member
Re: Unwanted elimination of zero in POST value
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.
-
Sep 7th, 2005, 11:00 PM
#6
Re: Unwanted elimination of zero in POST value
 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'];
-
Sep 8th, 2005, 11:40 AM
#7
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|