<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>web form &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/web-form/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>Automatically Upload Images with PHP Directly from the URI</title>
		<link>/2010/09/10/automatically-upload-images-with-php-directly-from-the-uri/</link>
		<comments>/2010/09/10/automatically-upload-images-with-php-directly-from-the-uri/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 06:49:54 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[automatic upload]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Mac OS X Server]]></category>
		<category><![CDATA[php tutorial]]></category>
		<category><![CDATA[php upload]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[web form]]></category>
		<category><![CDATA[Windows Explorer]]></category>
		<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1973</guid>
		<description><![CDATA[It is a simple task to upload images on the server with PHP using a simple web form. Than everything&#8217;s in the $_FILES array and after submitting the form the file&#8217;s on the server. By simply move_uploaded_file you can change its location on the server to the desired folder. However is there a way to &#8230; <a href="/2010/09/10/automatically-upload-images-with-php-directly-from-the-uri/" class="more-link">Continue reading <span class="screen-reader-text">Automatically Upload Images with PHP Directly from the URI</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2011/01/18/download-images-with-php/" rel="bookmark" title="Download Images with PHP">Download Images with PHP </a></li>
<li><a href="/2011/02/25/how-to-collect-the-images-and-meta-tags-from-a-webpage-with-php/" rel="bookmark" title="How to Collect the Images and Meta Tags from a Webpage with PHP">How to Collect the Images and Meta Tags from a Webpage with PHP </a></li>
<li><a href="/2010/03/05/video-sites-must-use-mp4-and-only-mp4/" rel="bookmark" title="Video sites must use &#8230; mp4 and only mp4!">Video sites must use &#8230; mp4 and only mp4! </a></li>
<li><a href="/2009/04/23/when-you-should-use-base64-for-images/" rel="bookmark" title="When you should use base64 for images">When you should use base64 for images </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>It is a simple task to upload images on the server with PHP using a simple web form. Than everything&#8217;s in the $_FILES array and after submitting the form the file&#8217;s on the server. By simply move_uploaded_file you can change its location on the server to the desired folder.</p>
<p>However is there a way to &#8220;upload&#8221; files without using a web form, but only by telling the PHP script where to find the image. First and most important the image should be web visible and accessible by HTTP.</p>
<p>The solution is quite easy &#8211; you can grab the file using file_get_contents, and than put it on the desired server folder with file_put_contents. Here&#8217;s some source:</p>
<pre lang="php">$image = file_get_contents('http://www.example.com/image.jpg');
file_put_contents('/var/www/my.jpg', $image);
</pre>
<h2>Extending the Case</h2>
<p>You can go even further by downloading any kind of files with the same approach. What will be the case for an mp4 video is shown in the next example:</p>
<pre lang="php">$video = file_get_contents('http://www.example.com/video.mp4');
file_put_contents('/var/www/my.mp4', $video);
</pre>
<h2>Usage</h2>
<p>This can be quite useful when trying to automate an remote upload process. In this case when somebody uploads an image on his site, you can duplicate this file on your server! However don&#8217;t forget the <strong>copyrights</strong>!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2011/01/18/download-images-with-php/" rel="bookmark" title="Download Images with PHP">Download Images with PHP </a></li>
<li><a href="/2011/02/25/how-to-collect-the-images-and-meta-tags-from-a-webpage-with-php/" rel="bookmark" title="How to Collect the Images and Meta Tags from a Webpage with PHP">How to Collect the Images and Meta Tags from a Webpage with PHP </a></li>
<li><a href="/2010/03/05/video-sites-must-use-mp4-and-only-mp4/" rel="bookmark" title="Video sites must use &#8230; mp4 and only mp4!">Video sites must use &#8230; mp4 and only mp4! </a></li>
<li><a href="/2009/04/23/when-you-should-use-base64-for-images/" rel="bookmark" title="When you should use base64 for images">When you should use base64 for images </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/09/10/automatically-upload-images-with-php-directly-from-the-uri/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://www.example.com/video.mp4" length="0" type="video/mp4" />
		</item>
		<item>
		<title>One Form &#8211; Multiple DB Records</title>
		<link>/2010/06/04/one-form-multiple-db-records/</link>
		<comments>/2010/06/04/one-form-multiple-db-records/#respond</comments>
		<pubDate>Fri, 04 Jun 2010 12:05:08 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Control flow]]></category>
		<category><![CDATA[elegant solution]]></category>
		<category><![CDATA[Foreach]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Iterator]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[web form]]></category>

		<guid isPermaLink="false">/?p=1584</guid>
		<description><![CDATA[I&#8217;ve the impression that even it&#8217;s a simple technique it remains quite misunderstood! What&#8217;s the Goal? You&#8217;ve a simple HTML form with several groups of form elements. Imagine the situation with title and link groups. You can have 1, 2 or more title/link pairs which you&#8217;d like to save in a database table, where perhaps &#8230; <a href="/2010/06/04/one-form-multiple-db-records/" class="more-link">Continue reading <span class="screen-reader-text">One Form &#8211; Multiple DB Records</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/04/09/secure-forms-with-zend-framework/" rel="bookmark" title="Secure Forms with Zend Framework">Secure Forms with Zend Framework </a></li>
<li><a href="/2010/04/20/how-to-sanitize-user-input-in-php/" rel="bookmark" title="How to Sanitize User Input in PHP?">How to Sanitize User Input in PHP? </a></li>
<li><a href="/2010/09/10/automatically-upload-images-with-php-directly-from-the-uri/" rel="bookmark" title="Automatically Upload Images with PHP Directly from the URI">Automatically Upload Images with PHP Directly from the URI </a></li>
<li><a href="/2010/11/03/how-to-overcome-zend_cache_frontend_pages-problem-with-cookies/" rel="bookmark" title="How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies">How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve the impression that even it&#8217;s a simple technique it remains quite misunderstood!</p>
<h2>What&#8217;s the Goal?</h2>
<p>You&#8217;ve a simple HTML form with several groups of form elements. Imagine the situation with title and link groups. You can have 1, 2 or more title/link pairs which you&#8217;d like to save in a database table, where perhaps there are only three columns &#8211; id, title, link.</p>
<h2>What is the Shortest Path to the Solution?</h2>
<p>In fact the task can be done by many ways, but there&#8217;s one really elegant solution. As it appears in many occasions PHP and HTML are born to work together!</p>
<h3>1. First Step</h3>
<p>Create your web form by simply modifying a bit the element names. Usually when you have an input you simply name it after the database column or something similar.</p>
<pre lang="html4strict">
<form method="POST">
	<input type="text" name="db_column_name" />
</form>
</pre>
<p>In reality PHP and HTML allows the name to be an array element, just like so:</p>
<pre lang="html4strict">
<form method="POST">
	<input type="text" name="link[0][title]" />
	<input type="text" name="link[0][url]" />
	
	<input type="text" name="link[1][title]" />
	<input type="text" name="link[1][url]" />
</form>
</pre>
<h3>2. Second Step</h3>
<p>Than all this comes in the _POST array in PHP, but formatted in an array manner, so you can simply foreach it!</p>
<pre lang="php">
<?php

foreach ($_POST['link'] as $link) {
	insert_into_db($link['title'], $link['url']);
}

?>
</pre>
<p>That is simply enough!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/04/09/secure-forms-with-zend-framework/" rel="bookmark" title="Secure Forms with Zend Framework">Secure Forms with Zend Framework </a></li>
<li><a href="/2010/04/20/how-to-sanitize-user-input-in-php/" rel="bookmark" title="How to Sanitize User Input in PHP?">How to Sanitize User Input in PHP? </a></li>
<li><a href="/2010/09/10/automatically-upload-images-with-php-directly-from-the-uri/" rel="bookmark" title="Automatically Upload Images with PHP Directly from the URI">Automatically Upload Images with PHP Directly from the URI </a></li>
<li><a href="/2010/11/03/how-to-overcome-zend_cache_frontend_pages-problem-with-cookies/" rel="bookmark" title="How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies">How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/06/04/one-form-multiple-db-records/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using rand() for a CAPTCHA!</title>
		<link>/2010/05/01/using-rand-for-a-captcha/</link>
		<comments>/2010/05/01/using-rand-for-a-captcha/#comments</comments>
		<pubDate>Sat, 01 May 2010 17:22:24 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[CAPTCHA]]></category>
		<category><![CDATA[Computer security]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[web form]]></category>

		<guid isPermaLink="false">/?p=1521</guid>
		<description><![CDATA[What if you have to add a simple CAPTCHA for a web form asking the user to sum two numbers. Will you prefer to use rand() to generate those two numbers? Some may say this is too predictable!<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/05/25/javascript-random-numbers/" rel="bookmark" title="JavaScript random numbers">JavaScript random numbers </a></li>
<li><a href="/2010/11/03/how-to-overcome-zend_cache_frontend_pages-problem-with-cookies/" rel="bookmark" title="How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies">How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies </a></li>
<li><a href="/2010/09/10/automatically-upload-images-with-php-directly-from-the-uri/" rel="bookmark" title="Automatically Upload Images with PHP Directly from the URI">Automatically Upload Images with PHP Directly from the URI </a></li>
<li><a href="/2010/04/20/how-to-sanitize-user-input-in-php/" rel="bookmark" title="How to Sanitize User Input in PHP?">How to Sanitize User Input in PHP? </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>What if you have to add a simple CAPTCHA for a web form asking the user to sum two numbers. Will you prefer to use <strong>rand()</strong> to generate those two numbers? Some may say this is too predictable!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/05/25/javascript-random-numbers/" rel="bookmark" title="JavaScript random numbers">JavaScript random numbers </a></li>
<li><a href="/2010/11/03/how-to-overcome-zend_cache_frontend_pages-problem-with-cookies/" rel="bookmark" title="How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies">How to Overcome Zend_Cache_Frontend_Page&#8217;s Problem with Cookies </a></li>
<li><a href="/2010/09/10/automatically-upload-images-with-php-directly-from-the-uri/" rel="bookmark" title="Automatically Upload Images with PHP Directly from the URI">Automatically Upload Images with PHP Directly from the URI </a></li>
<li><a href="/2010/04/20/how-to-sanitize-user-input-in-php/" rel="bookmark" title="How to Sanitize User Input in PHP?">How to Sanitize User Input in PHP? </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/05/01/using-rand-for-a-captcha/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Zend Framework validators &#8211; Zend_Validate_Db_RecordExists</title>
		<link>/2010/01/25/using-zend-framework-validators-zend_validate_db_recordexists/</link>
		<comments>/2010/01/25/using-zend-framework-validators-zend_validate_db_recordexists/#respond</comments>
		<pubDate>Mon, 25 Jan 2010 05:57:50 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Integrated development environments]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Software framework]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Validator]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>
		<category><![CDATA[web form]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Zend_Validate_Db_RecordExists]]></category>

		<guid isPermaLink="false">/?p=854</guid>
		<description><![CDATA[What are validators? In very very breve these are methods which can validate some data, usually user input, against some specific rules. Imagine there’s a web form that is always checked for empty fields or some fields that may contain valid e-mail addresses. This is so common that became everyday routine to almost all of &#8230; <a href="/2010/01/25/using-zend-framework-validators-zend_validate_db_recordexists/" class="more-link">Continue reading <span class="screen-reader-text">Using Zend Framework validators &#8211; Zend_Validate_Db_RecordExists</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/07/22/zend_validate_db_recordexists-in-zend-framework-1-10/" rel="bookmark" title="Zend_Validate_Db_RecordExists in Zend Framework 1.10+">Zend_Validate_Db_RecordExists in Zend Framework 1.10+ </a></li>
<li><a href="/2010/07/06/zend-framework-simple-acl-front-controller-plugin/" rel="bookmark" title="Zend Framework: Simple Acl Front Controller Plugin">Zend Framework: Simple Acl Front Controller Plugin </a></li>
<li><a href="/2010/06/10/json-and-zend-framework-zend_json/" rel="bookmark" title="JSON and Zend Framework? &#8211; Zend_Json">JSON and Zend Framework? &#8211; Zend_Json </a></li>
<li><a href="/2010/08/06/setting-up-zend-framework-with-modules/" rel="bookmark" title="Setting Up Zend Framework with Modules">Setting Up Zend Framework with Modules </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>What are validators?</h2>
<p>In very very breve these are methods which can validate some data, usually user input, against some specific rules. Imagine there’s a web form that is always checked for empty fields or some fields that may contain valid e-mail addresses. This is so common that became everyday routine to almost all of us. However smart developers make abstractions that help them reuse all this functionality. Even smarter developers make use of frameworks. And for those of you, using Zend Framework, there’s no need to write most of the common used validators, simply because they come with the framework itself.</p>
<p>Technically you’ve various validators in zend, such as <strong>Zend_Validate_Alnum</strong>, <strong>Zend_Validate_Email</strong> or <strong>Zend_Validate_Regex</strong>. All these are extremely useful when it comes to automatic, bullet proof validation, but I’m going to talk more about one specific validator.</p>
<h2>Zend_Validate_Db_RecordExists</h2>
<p>Although the implementation is nothing more than just a chunk of code and doesn’t pretend to be difficult, the idea of such validator is genius indeed. It really helps you do some amazing job.</p>
<p>Image you have to check some database record existence. Then comes in help this validator. In fact I’m pretty sure almost everyone has experience with such kind of task. Simply because the registration process almost always requires it. When you try to register new user you more often check for the username existence. Although you may solve the problem with other technique by catching the exception the database is throwing for duplicate entries, this should be assumed just as an example.</p>
<p>I’m pretty sure this validator can be really useful in many occasions!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/07/22/zend_validate_db_recordexists-in-zend-framework-1-10/" rel="bookmark" title="Zend_Validate_Db_RecordExists in Zend Framework 1.10+">Zend_Validate_Db_RecordExists in Zend Framework 1.10+ </a></li>
<li><a href="/2010/07/06/zend-framework-simple-acl-front-controller-plugin/" rel="bookmark" title="Zend Framework: Simple Acl Front Controller Plugin">Zend Framework: Simple Acl Front Controller Plugin </a></li>
<li><a href="/2010/06/10/json-and-zend-framework-zend_json/" rel="bookmark" title="JSON and Zend Framework? &#8211; Zend_Json">JSON and Zend Framework? &#8211; Zend_Json </a></li>
<li><a href="/2010/08/06/setting-up-zend-framework-with-modules/" rel="bookmark" title="Setting Up Zend Framework with Modules">Setting Up Zend Framework with Modules </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/01/25/using-zend-framework-validators-zend_validate_db_recordexists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
