Reply to Re: post data from a form and special character: " ' " and " / "

Your name:

Reply:


Posted by Hilarion on 10/10/10 11:25

> > [snip]
> > THE PROBLEM: [snip]
> > if I have insert for example a " ' "
> > the field will be filled with " \' " ... IF " \ " then " \\ "
> > If I submit the form again and there are some more errors... \\ becomes \\\
> > and \\\\ and so on...
>
> http://us3.php.net/manual/en/function.urlencode.php
>
> The format of the posted values would be:
> <input type="text" name="field"
> value="<?=urlencode($_POST['field'])?>">

This will not help and it should not be used for <input> values.
"urlencode" is for passing data in the URL (if you construct
the URL in the PHP code). When you want the data to be
properly encoded for attribute values (or you want to output
text "as is" so it's not interpreted as HTML), then you should
use "htmlspecialchars":

<input type="text" name="field"
value="<?php echo htmlspecialchars( $_POST['field'] ); ?>" />

If you are using single quotes to quote attribute values,
then you should also "tell" the function (by using proper
parameters) that it should also encode the single quote char.

You should also strip slashes added by magicquotes_gpc (or
magicquotes_runtime) before using "htmlspecialchars" (see
my previous post inn this topic).


Hilarion

[Back to original 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

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