You are here: Quotes and the invisible string « PHP Language « IT news, forums, messages
Quotes and the invisible string

Posted by Laiverd.COM on 03/29/07 19:48

This probably very basic, but my searches and attempts sofar have brought me
nowhere. This is the situation: I have a form with a city field which is
submitted for validation before data are entered into a db. When errors are
found, the user sees the form again with all posted values again in their
respective fields. This all works pretty fine ... except when I have an
entry which starts with a single quote ('). As soon as such an entry is
posted, it will never turn up in the form again after validation.
I found out (at least that is what people are making me believe ;) ) that
this has something to do with magic_quotes being on in the php.ini.
I have tried all kinds of combinations of stripslashes and addslashes, have
used get_magic_quotes_gpc(); to turn it of, even set it to off in my
configuration ... nothing helps: the value will not show up the second time
the form is displayed.

This is what i have
THE FORM PART
<input name='city' type='text' value='".$_POST['city']."' class='big' />


THE VALIDATION
if(!isValid("name", $_POST['city'])){
$errorFlag = false;
$errors['errors'] = true;
$errors['city_err'] = true;
}

THE PART OF THE ISVALID function used
function isValid($type, $string){
$string = trim($string);
switch ($type){
//...
case "name":
return ereg(VALID_NAME,$string);
break;
//...
default:
echo "No valid type specified for check";
break;
}
}


THE REGEXP (which would now return a false for any city with a ' ,but that's
beside the point I think)
define("VALID_NAME","^([A-Z]{1})([a-zA-Z\s \-]+)([a-z])$");

I'm really running out of options here, so if anyone could shed a light on
this ..

Thanks,
John

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация