hey,

I have a strange problem, when a user inputs the quantity into a text input field in a 
cart, I want to be able to test to see if the value is a integer if it isn't then 
default it to 1

if ( !is_int($Qty) ) {
$Qty = 1;
}

Looks ok, should work in theory, but it doesn't if I use this test, the update on the 
database fails, take it out and it works, so if a user was to type "f" in the quantity 
field in the cart and hit update because the quantity field is int(2) in the database 
it will default to 0 which I do not want. I have also tried to set the type before the 
update like so:

$Qty = settype($Qty, "integer");

This also will make the update fail, how would I make sure a user does not type 
characters in the quantity field without using  javascript or ereg stuff to check the 
values? I just want to default the quantity to 1 if a invailid quantity is inputted.

If there is no obvious soulution then I will use a piece of javascript to check the 
field onSubmit for illegal characters and alert the user I guess.

Regards,

Joseph

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to