<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Smart web form validation with PHP</title>
	<atom:link href="http://briancray.com/2009/09/18/web-form-validation-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://briancray.com/2009/09/18/web-form-validation-php/</link>
	<description>User Experience Design, Web Development, and Internet Marketing</description>
	<lastBuildDate>Fri, 30 Jul 2010 19:34:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
	<atom:link rel="hub" href="http://superfeedr.com/hubbub" />
		<item>
		<title>By: Brian Cray</title>
		<link>http://briancray.com/2009/09/18/web-form-validation-php/#comment-29216</link>
		<dc:creator>Brian Cray</dc:creator>
		<pubDate>Mon, 21 Sep 2009 17:42:14 +0000</pubDate>
		<guid isPermaLink="false">http://briancray.com/?p=1288#comment-29216</guid>
		<description>Tutorial City: Very cool, I didn&#039;t realize those existed on top of filter_var.</description>
		<content:encoded><![CDATA[<p>Tutorial City: Very cool, I didn&#8217;t realize those existed on top of filter_var.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tutorial City</title>
		<link>http://briancray.com/2009/09/18/web-form-validation-php/#comment-29214</link>
		<dc:creator>Tutorial City</dc:creator>
		<pubDate>Mon, 21 Sep 2009 16:05:42 +0000</pubDate>
		<guid isPermaLink="false">http://briancray.com/?p=1288#comment-29214</guid>
		<description>&lt;strong&gt;Just a note:&lt;/strong&gt; &lt;em&gt;filter_var_array&lt;/em&gt; and &lt;em&gt;filter_input_array&lt;/em&gt; were created to handle arrays, sou you do not need to use &lt;em&gt;array_map&lt;/em&gt;</description>
		<content:encoded><![CDATA[<p><strong>Just a note:</strong> <em>filter_var_array</em> and <em>filter_input_array</em> were created to handle arrays, sou you do not need to use <em>array_map</em></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Cray</title>
		<link>http://briancray.com/2009/09/18/web-form-validation-php/#comment-29132</link>
		<dc:creator>Brian Cray</dc:creator>
		<pubDate>Sat, 19 Sep 2009 17:30:53 +0000</pubDate>
		<guid isPermaLink="false">http://briancray.com/?p=1288#comment-29132</guid>
		<description>Brian: cool use of the array_map function for sure, and good point about the XSS attack. I wanted to emphasize the methodology and extra filtering should always occur on user input, such as htmlspecialchars or strip_tags, depending on how the input data will be displayed. Thanks so much for your insight!</description>
		<content:encoded><![CDATA[<p>Brian: cool use of the array_map function for sure, and good point about the XSS attack. I wanted to emphasize the methodology and extra filtering should always occur on user input, such as htmlspecialchars or strip_tags, depending on how the input data will be displayed. Thanks so much for your insight!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Reavis</title>
		<link>http://briancray.com/2009/09/18/web-form-validation-php/#comment-29131</link>
		<dc:creator>Brian Reavis</dc:creator>
		<pubDate>Sat, 19 Sep 2009 17:16:33 +0000</pubDate>
		<guid isPermaLink="false">http://briancray.com/?p=1288#comment-29131</guid>
		<description>As Michael said, control of data validation should never be put in the hands of the user. 

It&#039;d be super easy for me to open Firebug and adjust the &#039;name&#039; attribute on your form fields to insert whatever I like in your database. That&#039;s not hacking session vars. If you use this with the assumption that the data going into your database is solid (like most app developers would, for basic fields like email addresses at least), XSS holes will pop up all over the place. I could change  &quot;email_required_emailaddress&quot; to &quot;email&quot; and send: 

&lt;code&gt;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;/*send cookie data to remote source here*/&lt;/script&gt;&lt;/code&gt;

...to steal users&#039; passwords. If people have accounts and data on your CMS, security really should be a concern---no matter how difficult you perceive hacking to be. Data validation isn&#039;t something that just affects the person sending the form. If data isn&#039;t validated/sanitized properly, it becomes everyone&#039;s problem and concern.

Also, a bit of a side note: The &lt;em&gt;array_map&lt;/em&gt; function is a really handy one to use. Your sanitation step could be a lot faster and smaller:

&lt;code&gt;$postVars = array_map(&#039;trim&#039;, get_magic_quotes_gpc() ? array_map(&#039;stripslashes&#039;, $_POST) : $_POST);&lt;/code&gt;

Anyways, just my two cents. All the best.</description>
		<content:encoded><![CDATA[<p>As Michael said, control of data validation should never be put in the hands of the user. </p>
<p>It&#8217;d be super easy for me to open Firebug and adjust the &#8216;name&#8217; attribute on your form fields to insert whatever I like in your database. That&#8217;s not hacking session vars. If you use this with the assumption that the data going into your database is solid (like most app developers would, for basic fields like email addresses at least), XSS holes will pop up all over the place. I could change  &#8220;email_required_emailaddress&#8221; to &#8220;email&#8221; and send: </p>
<p><code>"&gt;&lt;script type="text/javascript"&gt;/*send cookie data to remote source here*/&lt;/script&gt;</code></p>
<p>&#8230;to steal users&#8217; passwords. If people have accounts and data on your CMS, security really should be a concern&#8212;no matter how difficult you perceive hacking to be. Data validation isn&#8217;t something that just affects the person sending the form. If data isn&#8217;t validated/sanitized properly, it becomes everyone&#8217;s problem and concern.</p>
<p>Also, a bit of a side note: The <em>array_map</em> function is a really handy one to use. Your sanitation step could be a lot faster and smaller:</p>
<p><code>$postVars = array_map('trim', get_magic_quotes_gpc() ? array_map('stripslashes', $_POST) : $_POST);</code></p>
<p>Anyways, just my two cents. All the best.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Cray</title>
		<link>http://briancray.com/2009/09/18/web-form-validation-php/#comment-29129</link>
		<dc:creator>Brian Cray</dc:creator>
		<pubDate>Sat, 19 Sep 2009 16:38:13 +0000</pubDate>
		<guid isPermaLink="false">http://briancray.com/?p=1288#comment-29129</guid>
		<description>David: You&#039;re right, the idea here is to separate back-end and front-end development in cases where it&#039;s handled by two different people. Great suggestions!

Baba Nutboltoo: filter_var is definitely the way to go, as I outlined in &quot;Things to consider about this method.&quot; However, many people are not running PHP 5.2.0 or above, which is required to use filter_var. I do like the idea to stay with KISS =)</description>
		<content:encoded><![CDATA[<p>David: You&#8217;re right, the idea here is to separate back-end and front-end development in cases where it&#8217;s handled by two different people. Great suggestions!</p>
<p>Baba Nutboltoo: filter_var is definitely the way to go, as I outlined in &#8220;Things to consider about this method.&#8221; However, many people are not running PHP 5.2.0 or above, which is required to use filter_var. I do like the idea to stay with KISS =)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AntonioCS</title>
		<link>http://briancray.com/2009/09/18/web-form-validation-php/#comment-29126</link>
		<dc:creator>AntonioCS</dc:creator>
		<pubDate>Sat, 19 Sep 2009 15:44:57 +0000</pubDate>
		<guid isPermaLink="false">http://briancray.com/?p=1288#comment-29126</guid>
		<description>This method is great for client side validation, if you also have server side validation.

I thinks there is a jQuery plugin that does something like this (looks at the fields name to know how to validate it).

Good article :)</description>
		<content:encoded><![CDATA[<p>This method is great for client side validation, if you also have server side validation.</p>
<p>I thinks there is a jQuery plugin that does something like this (looks at the fields name to know how to validate it).</p>
<p>Good article <img src='http://briancray.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Smart Web Form Validation With PHP &#124; Design Newz</title>
		<link>http://briancray.com/2009/09/18/web-form-validation-php/#comment-29125</link>
		<dc:creator>Smart Web Form Validation With PHP &#124; Design Newz</dc:creator>
		<pubDate>Sat, 19 Sep 2009 15:32:26 +0000</pubDate>
		<guid isPermaLink="false">http://briancray.com/?p=1288#comment-29125</guid>
		<description>[...] Smart Web Form Validation With PHP [...]</description>
		<content:encoded><![CDATA[<p>[...] Smart Web Form Validation With PHP [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tutorial City</title>
		<link>http://briancray.com/2009/09/18/web-form-validation-php/#comment-29116</link>
		<dc:creator>Tutorial City</dc:creator>
		<pubDate>Sat, 19 Sep 2009 11:13:33 +0000</pubDate>
		<guid isPermaLink="false">http://briancray.com/?p=1288#comment-29116</guid>
		<description>I think it&#039;s a good decision to use &lt;em&gt;filter_var&lt;/em&gt;. this library has almost anything you would want to, and even an option to use your own regular expressions. The best idea(my opinion) is to create a class to hold all validation, and use it across all the projects(maybe almost all). ;)</description>
		<content:encoded><![CDATA[<p>I think it&#8217;s a good decision to use <em>filter_var</em>. this library has almost anything you would want to, and even an option to use your own regular expressions. The best idea(my opinion) is to create a class to hold all validation, and use it across all the projects(maybe almost all). <img src='http://briancray.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Baba Nutboltoo</title>
		<link>http://briancray.com/2009/09/18/web-form-validation-php/#comment-29114</link>
		<dc:creator>Baba Nutboltoo</dc:creator>
		<pubDate>Sat, 19 Sep 2009 09:38:46 +0000</pubDate>
		<guid isPermaLink="false">http://briancray.com/?p=1288#comment-29114</guid>
		<description>Your clients won&#039;t pay you more for web services if you make them in this way!! 

&quot;This actually isn’t what I’m using in my CMS, but I thought about it while I was writing my CMS, and I thought it was unique enough to share.&quot;

- Please don&#039;t share things which you didn&#039;t use. First use it, test it, check if there is any error or hole then fix them and after then share it. PHP has a good set of functions to check these validations : filter_var, ctype_alnum, ctype_alpha etc.. Then why take the heck to write those regular expressions? Just learn how to KISS and effective :D</description>
		<content:encoded><![CDATA[<p>Your clients won&#8217;t pay you more for web services if you make them in this way!! </p>
<p>&#8220;This actually isn’t what I’m using in my CMS, but I thought about it while I was writing my CMS, and I thought it was unique enough to share.&#8221;</p>
<p>- Please don&#8217;t share things which you didn&#8217;t use. First use it, test it, check if there is any error or hole then fix them and after then share it. PHP has a good set of functions to check these validations : filter_var, ctype_alnum, ctype_alpha etc.. Then why take the heck to write those regular expressions? Just learn how to KISS and effective <img src='http://briancray.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://briancray.com/2009/09/18/web-form-validation-php/#comment-29108</link>
		<dc:creator>david</dc:creator>
		<pubDate>Sat, 19 Sep 2009 08:07:32 +0000</pubDate>
		<guid isPermaLink="false">http://briancray.com/?p=1288#comment-29108</guid>
		<description>If your method is only used to set php validation it&#039;s a bad process. And why can&#039;t you use a fieldname that is also a rulename? The fieldname gets split off before the the rules are checked. 

I think the use of the underscore to split the fieldname and the rules is very limiting. It&#039;s better to use more metacharacters, for example fieldname.rule1-rule2:param

A way to improve security is to process the html to extract the rules from the fields and only leave the name of the field when the form gets displayed. 

It&#039;s not a bad idea if you think about giving CMS mods the rights to create forms without messing with code but it&#039;s too basic to call it smart.</description>
		<content:encoded><![CDATA[<p>If your method is only used to set php validation it&#8217;s a bad process. And why can&#8217;t you use a fieldname that is also a rulename? The fieldname gets split off before the the rules are checked. </p>
<p>I think the use of the underscore to split the fieldname and the rules is very limiting. It&#8217;s better to use more metacharacters, for example fieldname.rule1-rule2:param</p>
<p>A way to improve security is to process the html to extract the rules from the fields and only leave the name of the field when the form gets displayed. </p>
<p>It&#8217;s not a bad idea if you think about giving CMS mods the rights to create forms without messing with code but it&#8217;s too basic to call it smart.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
