Hi
Usually when I have a problem coding it lasts for a few hours or until I find a fix somewhere on the net but I have been stuck on this problem for about 2 days and I cannot find anything relavent on the internet.
When I submit a form (form.php) to a processing page (add.php) any text with more than one zero at the end of the string, has the zeros eliminated. The main text box that I am using will take a number but this also happens in a textbox that I want to take text only [a-z0-9]
e.g.
text field = 1 => output after post = 1
text field = 10 => output after post = 10
text field = 100 => output after post = 1
text field = t10 => output after post = t10
text field = t100 => output after post = t1
text field = t100t => output after post = t100t
text field = 220.00 => output 22
text field = 220.02 => output 220.02
As you can see the problem occurs if the last characters of the textbox are 00 and the program will remove all trailing zeros from the string. The same problem occurs if the form type='number'.
I have ran loads of tests to establish if there is an error in my code but it happens as soon as aVar[$i]=$_POST['aTextbox']; is executed
the value of aVar[$i] is as shown on the ouput details above
I can paste in some of the code if you like but from what I can tell, it's a general problem
Apologies if this is a silly question and i'm missing something basic.
Thanks
Tim
Missing Zeros when posting html form data
Moderator: General Moderators
Missing Zeros when posting html form data
Last edited by ov3rfl0w on Mon Feb 26, 2007 6:55 am, edited 1 time in total.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
feyd | Please use
It needs a bit of fiddling to deal with decimals but it shouldn't be a problem.
Thanks for the nudge in the right direction
Much appreciated
Tim
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Thanks for the reply...
I've been messing with it and here's the solution I came up with:Code: Select all
$i=0;
while(sizeof($columns)-1 >= $i){ //the amount of columns the form is submitting
if(strlen($_POST[$columns[$i]])!=strlen($columnsContent[$i])){ //if the pre posted string length is not the same as the post posted data
$columnsContent[$i]=str_pad($columnsContent[$i],strlen($_POST[$columns[$i]]),"0",STR_PAD_RIGHT); //add the zeros on the end until the string length matches the length
}
if($addQuotes[$i]==true){ //if the item requires quotes to be accepted in sql
$columnsContent[$i] = "'".$columnsContent[$i]."'"; //add the quotes
}
$aSQLMiddle = $aSQLMiddle.",".$columnsContent[$i]; //construct the sql
$i++; //next form field
}It needs a bit of fiddling to deal with decimals but it shouldn't be a problem.
Thanks for the nudge in the right direction
Much appreciated
Tim
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA