<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: ¿Como filtrar información que llega desde un formulario con PHP?</title>
	<atom:link href="http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/</link>
	<description>La página que siempre está en onda :)</description>
	<pubDate>Wed, 14 May 2008 00:38:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Victor De la Rocha</title>
		<link>http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-13985</link>
		<dc:creator>Victor De la Rocha</dc:creator>
		<pubDate>Thu, 24 Jan 2008 23:12:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-13985</guid>
		<description>uff, que apuro me está sacando este código en estos momentos... uff uff uff</description>
		<content:encoded><![CDATA[<p>uff, que apuro me está sacando este código en estos momentos... uff uff uff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Victor De la Rocha</title>
		<link>http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-13616</link>
		<dc:creator>Victor De la Rocha</dc:creator>
		<pubDate>Fri, 11 Jan 2008 23:31:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-13616</guid>
		<description>Si, buen punto. Antes deutilizar cualquier tipo de dato en una consulta sql o en un envío de emails hay que sanitizar los datos. 

Para utilizar en consultas SQL utilizo una &lt;a href="http://www.mis-algoritmos.com/2006/12/10/funcion-para-evitar-ataques-de-sql-injection/" title="sql_quote" rel="nofollow"&gt;función mas sencilla&lt;/a&gt;:
[php]function sql_quote($value){
        if(get_magic_quotes_gpc())
        $value = stripslashes($value);
       
        //check if this function exists
        if(function_exists("mysql_real_escape_string"))
                $value = mysql_real_escape_string( $value );
            else//for PHP version &lt; 4.3.0 use addslashes
                $value = addslashes( $value );
       
        return $value;
    }[/php]

Para utilizarla, solo hay que aplicarle a la cadena a filtrar la función y listo.

[php]$password = sql_quote($_POST['password']);
$query = mysql_query("SELECT * FROM usuarios WHERE usuario='admin' AND password='$password');[/php]

Y para evitar la alteración de el funcionamiento normal de las funciones de envío de emails, realmente no tengo idea pero creo que al final de cuentas es lo mismo. 

Para evitar eso siempre utilizo procedimientos  para asegurarme de que el email al que enviaré la información "REALMENTE sea un email", y en cuanto a las cabeceras (o headers), no las verifico y ni tampoco permito al usuario que las modifique.

Algo así hago para el envío de emails, aunque ya tengo mi versión mejorada en algúna de mis aplicaciones que estoy trabajando, pero esta es la versión que tengo online y la pueden encontrar en el código de &lt;a href="http://sabros.us" rel="nofollow"&gt;sabros.us.
[php]/// Funcion sacada de sabrosus, modificada por Victor Bracco...
function enviaMail($to, $title, $body, $from) {
       $rp     = trim($from);
       $org    = " sabros.us";
       $mailer = "sabros.us Mailer";

       $head   = '';
       $head  .= "Content-Type: text/html \r\n";
       $head  .= "Date: ". date('r'). " \r\n";
       $head  .= "Return-Path: $rp \r\n";
       $head  .= "From: $from \r\n";
       $head  .= "Sender: $from \r\n";
       $head  .= "Reply-To: $from \r\n";
       $head  .= "Organization: $org \r\n";
       $head  .= "X-Sender: $from \r\n";
       $head  .= "X-Priority: 3 \r\n";
       $head  .= "X-Mailer: $mailer \r\n";

       $body   = str_replace("\r\n", "\n", $body);
       $body   = str_replace("\n", "\r\n", $body);
       if(is_array($to)
       {
            for_each($to as $suscriptor)
            {
                    @mail($to, $title, $body, $head);
            }
       } else {
                    @mail($to, $title, $body, $head);
       }[/php]</description>
		<content:encoded><![CDATA[<p>Si, buen punto. Antes deutilizar cualquier tipo de dato en una consulta sql o en un envío de emails hay que sanitizar los datos. </p>
<p>Para utilizar en consultas SQL utilizo una <a href="http://www.mis-algoritmos.com/2006/12/10/funcion-para-evitar-ataques-de-sql-injection/" title="sql_quote" rel="nofollow">función mas sencilla</a>:</p>
<div class="hiliter"><strong>php: </strong>
<pre class="php"><span style="color: #000000; font-weight: bold;">function</span> sql_quote<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/get_magic_quotes_gpc"><span style="color: #000066;">get_magic_quotes_gpc</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #0000ff;">$value</span> = <a href="http://www.php.net/stripslashes"><span style="color: #000066;">stripslashes</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
        <span style="color: #808080; font-style: italic;">//check if this function exists</span>
        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/function_exists"><span style="color: #000066;">function_exists</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;mysql_real_escape_string&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #0000ff;">$value</span> = <a href="http://www.php.net/mysql_real_escape_string"><span style="color: #000066;">mysql_real_escape_string</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$value</span> <span style="color: #66cc66;">&#41;</span>;
            <span style="color: #b1b100;">else</span><span style="color: #808080; font-style: italic;">//for PHP version &lt; 4.3.0 use addslashes</span>
                <span style="color: #0000ff;">$value</span> = <a href="http://www.php.net/addslashes"><span style="color: #000066;">addslashes</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$value</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$value</span>;
    <span style="color: #66cc66;">&#125;</span></pre>
</div>
<p>Para utilizarla, solo hay que aplicarle a la cadena a filtrar la función y listo.</p>
<div class="hiliter"><strong>php: </strong>
<pre class="php"><span style="color: #0000ff;">$password</span> = sql_quote<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_POST</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'password'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0000ff;">$query</span> = <a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;SELECT * FROM usuarios WHERE usuario='admin' AND password='$password');</span></pre>
</div>
<p>Y para evitar la alteración de el funcionamiento normal de las funciones de envío de emails, realmente no tengo idea pero creo que al final de cuentas es lo mismo. </p>
<p>Para evitar eso siempre utilizo procedimientos  para asegurarme de que el email al que enviaré la información "REALMENTE sea un email", y en cuanto a las cabeceras (o headers), no las verifico y ni tampoco permito al usuario que las modifique.</p>
<p>Algo así hago para el envío de emails, aunque ya tengo mi versión mejorada en algúna de mis aplicaciones que estoy trabajando, pero esta es la versión que tengo online y la pueden encontrar en el código de <a href="http://sabros.us" rel="nofollow">sabros.us.</p>
<div class="hiliter"><strong>php: </strong>
<pre class="php"><span style="color: #808080; font-style: italic;">/// Funcion sacada de sabrosus, modificada por Victor Bracco...</span>
<span style="color: #000000; font-weight: bold;">function</span> enviaMail<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$to</span>, <span style="color: #0000ff;">$title</span>, <span style="color: #0000ff;">$body</span>, <span style="color: #0000ff;">$from</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
       <span style="color: #0000ff;">$rp</span>     = <a href="http://www.php.net/trim"><span style="color: #000066;">trim</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$from</span><span style="color: #66cc66;">&#41;</span>;
       <span style="color: #0000ff;">$org</span>    = <span style="color: #ff0000;">&quot; sabros.us&quot;</span>;
       <span style="color: #0000ff;">$mailer</span> = <span style="color: #ff0000;">&quot;sabros.us Mailer&quot;</span>;
&nbsp;
       <span style="color: #0000ff;">$head</span>   = <span style="color: #ff0000;">''</span>;
       <span style="color: #0000ff;">$head</span>  .= <span style="color: #ff0000;">&quot;Content-Type: text/html <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
       <span style="color: #0000ff;">$head</span>  .= <span style="color: #ff0000;">&quot;Date: &quot;</span>. <a href="http://www.php.net/date"><span style="color: #000066;">date</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'r'</span><span style="color: #66cc66;">&#41;</span>. <span style="color: #ff0000;">&quot; <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
       <span style="color: #0000ff;">$head</span>  .= <span style="color: #ff0000;">&quot;Return-Path: $rp <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
       <span style="color: #0000ff;">$head</span>  .= <span style="color: #ff0000;">&quot;From: $from <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
       <span style="color: #0000ff;">$head</span>  .= <span style="color: #ff0000;">&quot;Sender: $from <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
       <span style="color: #0000ff;">$head</span>  .= <span style="color: #ff0000;">&quot;Reply-To: $from <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
       <span style="color: #0000ff;">$head</span>  .= <span style="color: #ff0000;">&quot;Organization: $org <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
       <span style="color: #0000ff;">$head</span>  .= <span style="color: #ff0000;">&quot;X-Sender: $from <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
       <span style="color: #0000ff;">$head</span>  .= <span style="color: #ff0000;">&quot;X-Priority: 3 <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
       <span style="color: #0000ff;">$head</span>  .= <span style="color: #ff0000;">&quot;X-Mailer: $mailer <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
&nbsp;
       <span style="color: #0000ff;">$body</span>   = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, <span style="color: #0000ff;">$body</span><span style="color: #66cc66;">&#41;</span>;
       <span style="color: #0000ff;">$body</span>   = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, <span style="color: #0000ff;">$body</span><span style="color: #66cc66;">&#41;</span>;
       <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #000066;">is_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$to</span><span style="color: #66cc66;">&#41;</span>
       <span style="color: #66cc66;">&#123;</span>
            for_each<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$to</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$suscriptor</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#123;</span>
                    @<a href="http://www.php.net/mail"><span style="color: #000066;">mail</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$to</span>, <span style="color: #0000ff;">$title</span>, <span style="color: #0000ff;">$body</span>, <span style="color: #0000ff;">$head</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
       <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
                    @<a href="http://www.php.net/mail"><span style="color: #000066;">mail</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$to</span>, <span style="color: #0000ff;">$title</span>, <span style="color: #0000ff;">$body</span>, <span style="color: #0000ff;">$head</span><span style="color: #66cc66;">&#41;</span>;
       <span style="color: #66cc66;">&#125;</span></pre>
</div>
<p></a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jonaytom</title>
		<link>http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-13595</link>
		<dc:creator>jonaytom</dc:creator>
		<pubDate>Fri, 11 Jan 2008 15:09:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-13595</guid>
		<description>Aparte de la validación javascript antes de enviar el formulario, Para evitar que los hackers inserten código no deseado hagan sql o email injection también es recomendable hacer una validacion en el lado del servidor. Recomiendo usar una función como esta:


[php]function ValidarDatos($campo){
//Array con las posibles cadenas a utilizar por un hacker
$CadenasProhibidas = array("Content-Type:",
//evita email injection
"MIME-Version:", "Content-Transfer-Encoding:","Return-path:","Subject:","From:","Envelope-to:","To:","bcc:","cc:",
"UNION",
// evita sql injection
"DELETE","DROP","SELECT","INSERT","UPDATE","CRERATE","TRUNCATE","ALTER","INTO","DISTINCT","GROUP BY","WHERE","RENAME","DEFINE","UNDEFINE","PROMPT","ACCEPT","VIEW","COUNT","HAVING","'",'"',"{","}","[","]",
 // evita introducir direcciones web
"HOTMAIL","WWW",".COM","@","W W W",". c o m","http://",
//variables y comodines
"$", "&#38;","*");
 
//Comprobamos que entre los datos no se encuentre alguna de 
//las cadenas del array. Si se encuentra alguna cadena se 
//dirige a la página anterior 

foreach($CadenasProhibidas as $valor){ 
    if(strpos(strtolower($campo), strtolower($valor)) !== false){ 
		echo("
        alert('No puede introducir direcciones web, comillas, corchetes, código de programación o cualquier dato no relativo a los campos del formulario');
		history.back();");
        exit; 
        } 
    } 
} 
//Asignamos la variable POST y llamada a la función Validardatos($texto)
$texto= $_POST["texto"];
ValidarDatos($texto);[/php]</description>
		<content:encoded><![CDATA[<p>Aparte de la validación javascript antes de enviar el formulario, Para evitar que los hackers inserten código no deseado hagan sql o email injection también es recomendable hacer una validacion en el lado del servidor. Recomiendo usar una función como esta:</p>
<div class="hiliter"><strong>php: </strong>
<pre class="php"><span style="color: #000000; font-weight: bold;">function</span> ValidarDatos<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$campo</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
<span style="color: #808080; font-style: italic;">//Array con las posibles cadenas a utilizar por un hacker</span>
<span style="color: #0000ff;">$CadenasProhibidas</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Content-Type:&quot;</span>,
<span style="color: #808080; font-style: italic;">//evita email injection</span>
<span style="color: #ff0000;">&quot;MIME-Version:&quot;</span>, <span style="color: #ff0000;">&quot;Content-Transfer-Encoding:&quot;</span>,<span style="color: #ff0000;">&quot;Return-path:&quot;</span>,<span style="color: #ff0000;">&quot;Subject:&quot;</span>,<span style="color: #ff0000;">&quot;From:&quot;</span>,<span style="color: #ff0000;">&quot;Envelope-to:&quot;</span>,<span style="color: #ff0000;">&quot;To:&quot;</span>,<span style="color: #ff0000;">&quot;bcc:&quot;</span>,<span style="color: #ff0000;">&quot;cc:&quot;</span>,
<span style="color: #ff0000;">&quot;UNION&quot;</span>,
<span style="color: #808080; font-style: italic;">// evita sql injection</span>
<span style="color: #ff0000;">&quot;DELETE&quot;</span>,<span style="color: #ff0000;">&quot;DROP&quot;</span>,<span style="color: #ff0000;">&quot;SELECT&quot;</span>,<span style="color: #ff0000;">&quot;INSERT&quot;</span>,<span style="color: #ff0000;">&quot;UPDATE&quot;</span>,<span style="color: #ff0000;">&quot;CRERATE&quot;</span>,<span style="color: #ff0000;">&quot;TRUNCATE&quot;</span>,<span style="color: #ff0000;">&quot;ALTER&quot;</span>,<span style="color: #ff0000;">&quot;INTO&quot;</span>,<span style="color: #ff0000;">&quot;DISTINCT&quot;</span>,<span style="color: #ff0000;">&quot;GROUP BY&quot;</span>,<span style="color: #ff0000;">&quot;WHERE&quot;</span>,<span style="color: #ff0000;">&quot;RENAME&quot;</span>,<span style="color: #ff0000;">&quot;DEFINE&quot;</span>,<span style="color: #ff0000;">&quot;UNDEFINE&quot;</span>,<span style="color: #ff0000;">&quot;PROMPT&quot;</span>,<span style="color: #ff0000;">&quot;ACCEPT&quot;</span>,<span style="color: #ff0000;">&quot;VIEW&quot;</span>,<span style="color: #ff0000;">&quot;COUNT&quot;</span>,<span style="color: #ff0000;">&quot;HAVING&quot;</span>,<span style="color: #ff0000;">&quot;'&quot;</span>,<span style="color: #ff0000;">'&quot;'</span>,<span style="color: #ff0000;">&quot;{&quot;</span>,<span style="color: #ff0000;">&quot;}&quot;</span>,<span style="color: #ff0000;">&quot;[&quot;</span>,<span style="color: #ff0000;">&quot;]&quot;</span>,
 <span style="color: #808080; font-style: italic;">// evita introducir direcciones web</span>
<span style="color: #ff0000;">&quot;HOTMAIL&quot;</span>,<span style="color: #ff0000;">&quot;WWW&quot;</span>,<span style="color: #ff0000;">&quot;.COM&quot;</span>,<span style="color: #ff0000;">&quot;@&quot;</span>,<span style="color: #ff0000;">&quot;W W W&quot;</span>,<span style="color: #ff0000;">&quot;. c o m&quot;</span>,<span style="color: #ff0000;">&quot;http://&quot;</span>,
<span style="color: #808080; font-style: italic;">//variables y comodines</span>
<span style="color: #ff0000;">&quot;$&quot;</span>, <span style="color: #ff0000;">&quot;&#038;amp;&quot;</span>,<span style="color: #ff0000;">&quot;*&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">//Comprobamos que entre los datos no se encuentre alguna de </span>
<span style="color: #808080; font-style: italic;">//las cadenas del array. Si se encuentra alguna cadena se </span>
<span style="color: #808080; font-style: italic;">//dirige a la página anterior </span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$CadenasProhibidas</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$valor</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/strpos"><span style="color: #000066;">strpos</span></a><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/strtolower"><span style="color: #000066;">strtolower</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$campo</span><span style="color: #66cc66;">&#41;</span>, <a href="http://www.php.net/strtolower"><span style="color: #000066;">strtolower</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$valor</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> !== <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;
        alert('No puede introducir direcciones web, comillas, corchetes, código de programación o cualquier dato no relativo a los campos del formulario');
		history.back();&quot;</span><span style="color: #66cc66;">&#41;</span>;
        <a href="http://www.php.net/exit"><span style="color: #000066;">exit</span></a>;
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #808080; font-style: italic;">//Asignamos la variable POST y llamada a la función Validardatos($texto)</span>
<span style="color: #0000ff;">$texto</span>= <span style="color: #0000ff;">$_POST</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;texto&quot;</span><span style="color: #66cc66;">&#93;</span>;
ValidarDatos<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$texto</span><span style="color: #66cc66;">&#41;</span>;</pre>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Victor De la Rocha</title>
		<link>http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-12789</link>
		<dc:creator>Victor De la Rocha</dc:creator>
		<pubDate>Fri, 14 Dec 2007 01:48:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-12789</guid>
		<description>Hola @&lt;b&gt;Juan Carlos&lt;/b&gt;, no te preocupes, todo bien.

Para lograr que se vean los thumbnails, es necesario buscar en index.php al rededor de la línea 165, donde está algo como esto:

[php]echo "\t\t&lt;img class=\"preview\" src=\"http://www.webshotspro.com/thumb.php?url=".htmlspecialchars($row["enlace"])."\" alt=\"".htmlspecialchars($row["title"])."\" /&gt;";[/php]
 
y sustituirlo por esto:
 
[php]echo "\t\t&lt;img class=\"preview\" src=\"http://sabros.us/thumbs/?url=".htmlspecialchars($row["enlace"])."&#038;size=T\" alt=\"".htmlspecialchars($row["title"])."\" /&gt;";[/php] 

&lt;del datetime="2007-12-14T01:50:59+00:00"&gt;Esta información la obtuve de los foros de sabrosus (&lt;a href="http://sourceforge.net/forum/message.php?msg_id=4441794" rel="nofollow"&gt;Aquí&lt;/a&gt;)&lt;/del&gt; No es cierto, no recuerdo de donde la obtuve, sólo recuerdo que de alguna forma &lt;a href="http://www.pecesama.net" rel="nofollow"&gt;Pedro Santana&lt;/a&gt; tuvo que ver en esto :) ... De cualquier forma jé, esa es la solución :D</description>
		<content:encoded><![CDATA[<p>Hola @<b>Juan Carlos</b>, no te preocupes, todo bien.</p>
<p>Para lograr que se vean los thumbnails, es necesario buscar en index.php al rededor de la línea 165, donde está algo como esto:</p>
<div class="hiliter"><strong>php: </strong>
<pre class="php"><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;img class=<span style="color: #000099; font-weight: bold;">\&quot;</span>preview<span style="color: #000099; font-weight: bold;">\&quot;</span> src=<span style="color: #000099; font-weight: bold;">\&quot;</span><a href="http://www.webshotspro.com/thumb.php?url=&#038;quot" rel="nofollow">http://www.webshotspro.com/thumb.php?url=&#038;quot</a>;</span>.<a href="http://www.php.net/htmlspecialchars"><span style="color: #000066;">htmlspecialchars</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$row</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;enlace&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> alt=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>.<a href="http://www.php.net/htmlspecialchars"><span style="color: #000066;">htmlspecialchars</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$row</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;title&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;&quot;</span>;</pre>
</div>
<p>y sustituirlo por esto:</p>
<div class="hiliter"><strong>php: </strong>
<pre class="php"><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;img class=<span style="color: #000099; font-weight: bold;">\&quot;</span>preview<span style="color: #000099; font-weight: bold;">\&quot;</span> src=<span style="color: #000099; font-weight: bold;">\&quot;</span><a href="http://sabros.us/thumbs/?url=&#038;quot" rel="nofollow">http://sabros.us/thumbs/?url=&#038;quot</a>;</span>.<a href="http://www.php.net/htmlspecialchars"><span style="color: #000066;">htmlspecialchars</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$row</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;enlace&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">&quot;&#038;size=T<span style="color: #000099; font-weight: bold;">\&quot;</span> alt=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>.<a href="http://www.php.net/htmlspecialchars"><span style="color: #000066;">htmlspecialchars</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$row</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;title&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;&quot;</span>;</pre>
</div>
<p><del datetime="2007-12-14T01:50:59+00:00">Esta información la obtuve de los foros de sabrosus (<a href="http://sourceforge.net/forum/message.php?msg_id=4441794" rel="nofollow">Aquí</a>)</del> No es cierto, no recuerdo de donde la obtuve, sólo recuerdo que de alguna forma <a href="http://www.pecesama.net" rel="nofollow">Pedro Santana</a> tuvo que ver en esto <img src='http://www.mis-algoritmos.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ... De cualquier forma jé, esa es la solución <img src='http://www.mis-algoritmos.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Juan Carlos</title>
		<link>http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-12785</link>
		<dc:creator>Juan Carlos</dc:creator>
		<pubDate>Fri, 14 Dec 2007 00:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-12785</guid>
		<description>Ante todo mis disculpas por utilizar un comentario en un tema que no tiene nada que ver. Pero no encontré en el sitio un lugar de contacto. Agradecería me pudieras comentar como has logrado que en tu sabros.us se vean los thumbnails de los links. Desde ya muchas gracias.</description>
		<content:encoded><![CDATA[<p>Ante todo mis disculpas por utilizar un comentario en un tema que no tiene nada que ver. Pero no encontré en el sitio un lugar de contacto. Agradecería me pudieras comentar como has logrado que en tu sabros.us se vean los thumbnails de los links. Desde ya muchas gracias.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Victor De la Rocha</title>
		<link>http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-12662</link>
		<dc:creator>Victor De la Rocha</dc:creator>
		<pubDate>Fri, 07 Dec 2007 22:09:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-12662</guid>
		<description>uuh! la onda con estas funciones de PHP5 para el filtrado y validado de datos provenientes de alguna fuente insegura :D 

http://www.php.net/manual/en/ref.filter.php

De lujo!! ;)</description>
		<content:encoded><![CDATA[<p>uuh! la onda con estas funciones de PHP5 para el filtrado y validado de datos provenientes de alguna fuente insegura <img src='http://www.mis-algoritmos.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><a href="http://www.php.net/manual/en/ref.filter.php" rel="nofollow">http://www.php.net/manual/en/ref.filter.php</a></p>
<p>De lujo!! <img src='http://www.mis-algoritmos.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Victor De la Rocha</title>
		<link>http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-12398</link>
		<dc:creator>Victor De la Rocha</dc:creator>
		<pubDate>Mon, 26 Nov 2007 20:51:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-12398</guid>
		<description>Hola Jesús, gracias por tu dejarme tu punto de vista.

Lo que trato de hacer con este código es filtrar, recibir o validar uno a uno los campos que recibo desde un formulario que entran en un documento.

Se me da mucho la situación de que cambio de campos una y otra vez debido a cuestiones de trabajo por lo que tengo que estar haciendo un movedero de pequeños bloques de código para validar cada uno de los campos. 

Este código hace que yo no tenga que estar haciendo un pequeño bloque de código para validar (o recibir, filtrar) cada uno de los datos (o campos) y hacer todo de un solo golpe.

Hacerlo con JavaScript es una solución siempre y cuando esté activado el JavaScript en el navegador, pero y... ¿si no está activado? Todos los campos se van ir sin validar. Es por eso que considero hacerlo desde PHP :)

Gracias por dejar tu punto de vista, es muy bien bienvenido :D</description>
		<content:encoded><![CDATA[<p>Hola Jesús, gracias por tu dejarme tu punto de vista.</p>
<p>Lo que trato de hacer con este código es filtrar, recibir o validar uno a uno los campos que recibo desde un formulario que entran en un documento.</p>
<p>Se me da mucho la situación de que cambio de campos una y otra vez debido a cuestiones de trabajo por lo que tengo que estar haciendo un movedero de pequeños bloques de código para validar cada uno de los campos. </p>
<p>Este código hace que yo no tenga que estar haciendo un pequeño bloque de código para validar (o recibir, filtrar) cada uno de los datos (o campos) y hacer todo de un solo golpe.</p>
<p>Hacerlo con JavaScript es una solución siempre y cuando esté activado el JavaScript en el navegador, pero y... ¿si no está activado? Todos los campos se van ir sin validar. Es por eso que considero hacerlo desde PHP <img src='http://www.mis-algoritmos.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Gracias por dejar tu punto de vista, es muy bien bienvenido <img src='http://www.mis-algoritmos.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesús</title>
		<link>http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-12397</link>
		<dc:creator>Jesús</dc:creator>
		<pubDate>Mon, 26 Nov 2007 20:40:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-12397</guid>
		<description>hola, que tal?? he estado leyendo un poco tus codigos y particularmente este, pero de verdad no entiendo mucho para que sirve. a ver segun pude entender quieres filtrar a que ninghun campo quede vacio verdad???? creo que eso es más facil con un javascript y aparte no te saca de la pagina, bueno todo esto en mi humilde opinión. cuando tenga mas tiempo seguire hechando un ojo en tu web quew en general esta muy buena para compartir conocimientos entre la comunidad de programadores</description>
		<content:encoded><![CDATA[<p>hola, que tal?? he estado leyendo un poco tus codigos y particularmente este, pero de verdad no entiendo mucho para que sirve. a ver segun pude entender quieres filtrar a que ninghun campo quede vacio verdad???? creo que eso es más facil con un javascript y aparte no te saca de la pagina, bueno todo esto en mi humilde opinión. cuando tenga mas tiempo seguire hechando un ojo en tu web quew en general esta muy buena para compartir conocimientos entre la comunidad de programadores</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Victor De la Rocha</title>
		<link>http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-12043</link>
		<dc:creator>Victor De la Rocha</dc:creator>
		<pubDate>Thu, 15 Nov 2007 13:55:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-12043</guid>
		<description>@&lt;b&gt;Edgar J. Suárez&lt;/b&gt;: uff, yo mas flojo, por eso, no me cambio a rails :P ...

@&lt;b&gt;Stan&lt;/b&gt;: Pues ánimo :D póngase a aprender :) ... Aquí estamos pa lo que se ofrezca.</description>
		<content:encoded><![CDATA[<p>@<b>Edgar J. Suárez</b>: uff, yo mas flojo, por eso, no me cambio a rails <img src='http://www.mis-algoritmos.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ...</p>
<p>@<b>Stan</b>: Pues ánimo <img src='http://www.mis-algoritmos.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> póngase a aprender <img src='http://www.mis-algoritmos.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ... Aquí estamos pa lo que se ofrezca.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stan</title>
		<link>http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-11951</link>
		<dc:creator>Stan</dc:creator>
		<pubDate>Wed, 14 Nov 2007 00:04:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.mis-algoritmos.com/2007/11/13/%c2%bfcomo-filtrar-informacion-que-llega-desde-un-formulario-con-php/#comment-11951</guid>
		<description>Te estas aventando unos post's muy interesantes de un tiempo para aca, vere que se puede hacer :D</description>
		<content:encoded><![CDATA[<p>Te estas aventando unos post's muy interesantes de un tiempo para aca, vere que se puede hacer <img src='http://www.mis-algoritmos.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
</channel>
</rss>
