Forum Moderators: coopster

Message Too Old, No Replies

Form Validation problem

         

sfast

2:28 am on Jun 11, 2007 (gmt 0)

10+ Year Member



I am using form validations for different fields.
One of them for City as -

if(($_GET['app_city']) == ''){
$cityError = "Invalid or missing city";
$error++; }
else
{
$app_city = trim(stripcslashes($_GET['app_city'])) ;

If I typed City as - "My City",

If the validation fails, it shows City as - "My" instead.
Does not consider both the words.

Can somebody help me here, please?

Thanks

Gian04

3:59 am on Jun 11, 2007 (gmt 0)

10+ Year Member



Try This

$app_city = \"trim(stripcslashes($_GET['app_city']))\";

eelixduppy

2:42 pm on Jun 11, 2007 (gmt 0)



It should work as you have it. Try this to see what you get:

$app_city = trim(stripcslashes($_GET['app_city']));
echo $app_city;
echo $_GET['app_city'];

sfast

3:30 pm on Jun 11, 2007 (gmt 0)

10+ Year Member



eelixduppy,
it echoes - "My City" when I try
echo $app_city;
echo $_GET['app_city'];

But in the field, it still shows
My.

The way I print city in the field is -

echo 'City:
<input maxLength="35" size="20" name="app_city" value='.$app_city.'>' ;

sfast

3:31 pm on Jun 11, 2007 (gmt 0)

10+ Year Member



Gian04

$app_city = \"trim(stripcslashes($_GET['app_city']))\";

This is showing me errors.

eelixduppy

3:32 pm on Jun 11, 2007 (gmt 0)



There is your problem, then. You aren't surrounding it with quotes:

echo 'City:<input maxLength="35" size="20" name="app_city" value="'.$app_city.'">';

sfast

3:47 pm on Jun 11, 2007 (gmt 0)

10+ Year Member



huh...

How could I skip this small thing.
Thankyou.

eelixduppy

3:49 pm on Jun 11, 2007 (gmt 0)



It's usually the small things that are missed. Glad you got it resolved :)