<?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>Form &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/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>HTTP POST with PHP without cURL</title>
		<link>/2010/09/08/http-post-with-php-without-curl/</link>
		<comments>/2010/09/08/http-post-with-php-without-curl/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 21:47:27 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[Truth]]></category>

		<guid isPermaLink="false">/?p=1960</guid>
		<description><![CDATA[Awesome PHP It&#8217;s strange how powerful PHP can be. There&#8217;s a legend that cURL is the only way to perform a HTTP POST with PHP, but that isn&#8217;t the truth. An extremely useful script is by using stream_context_create: $optional_headers = null; $params = array('http' => array( 'method' => 'POST', 'content' => http_build_query(array('name' => 'my-name')))); if &#8230; <a href="/2010/09/08/http-post-with-php-without-curl/" class="more-link">Continue reading <span class="screen-reader-text">HTTP POST with PHP without cURL</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2011/04/13/post-with-zend_http_client/" rel="bookmark" title="POST with Zend_Http_Client">POST with Zend_Http_Client </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
<li><a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" rel="bookmark" title="Send Authenticated POST Request with Zend_Http_Client">Send Authenticated POST Request with Zend_Http_Client </a></li>
<li><a href="/2010/05/17/php-the-array-element-doesnt-exist-suppress-the-warnings/" rel="bookmark" title="PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings">PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Awesome PHP</h2>
<p><a href="/wp-content/uploads/2010/09/idea.jpeg"><img src="/wp-content/uploads/2010/09/idea.jpeg" alt="a great php idea!" title="idea" width="430" height="286" class="aligncenter size-full wp-image-1975" srcset="/wp-content/uploads/2010/09/idea.jpeg 430w, /wp-content/uploads/2010/09/idea-300x199.jpg 300w" sizes="(max-width: 430px) 100vw, 430px" /></a><br />
It&#8217;s strange how powerful PHP can be. There&#8217;s a legend that cURL is the only way to perform a HTTP POST with PHP, but that isn&#8217;t the truth. An extremely useful script is by using stream_context_create:</p>
<pre lang="php">
$optional_headers = null;
$params = array('http' => array(
                'method' => 'POST',
                'content' => http_build_query(array('name' => 'my-name'))));

if ($optional_headers !== null) {
    $params['http']['header'] = $optional_headers;
}

$ctx = stream_context_create($params);
$fp = @fopen('http://example.com/post.php', 'rb', false, $ctx);
</pre>
<p>Well this is only a snippet. You can change a lot this code and perform any request, but here&#8217;s a small start up. However note that this will do the same as while posting to example.com/post.php via web form!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2011/04/13/post-with-zend_http_client/" rel="bookmark" title="POST with Zend_Http_Client">POST with Zend_Http_Client </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
<li><a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" rel="bookmark" title="Send Authenticated POST Request with Zend_Http_Client">Send Authenticated POST Request with Zend_Http_Client </a></li>
<li><a href="/2010/05/17/php-the-array-element-doesnt-exist-suppress-the-warnings/" rel="bookmark" title="PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings">PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/09/08/http-post-with-php-without-curl/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Send Html Mails with Zend_Mail</title>
		<link>/2010/07/17/send-html-mails-with-zend_mail/</link>
		<comments>/2010/07/17/send-html-mails-with-zend_mail/#respond</comments>
		<pubDate>Sat, 17 Jul 2010 11:31:47 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[E-mail]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Spamming]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[web system]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1815</guid>
		<description><![CDATA[Typically you&#8217;d never like to send a non-html formatted mail from your web system. It&#8217;s ugly and it&#8217;s difficult to read. Instead of sending pure text, you&#8217;d like to add some images and styles. The way you can do it with Zend_Mail is simple enough. Replace the setBody method with setBodyHtml. Isn&#8217;t that natural? // &#8230; <a href="/2010/07/17/send-html-mails-with-zend_mail/" class="more-link">Continue reading <span class="screen-reader-text">Send Html Mails with Zend_Mail</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/03/25/send-mail-with-zend-framework/" rel="bookmark" title="Send Mail with Zend Framework">Send Mail with Zend Framework </a></li>
<li><a href="/2010/07/18/zend_mail-with-gmail/" rel="bookmark" title="Zend_Mail with GMail">Zend_Mail with GMail </a></li>
<li><a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" rel="bookmark" title="Send Authenticated POST Request with Zend_Http_Client">Send Authenticated POST Request with Zend_Http_Client </a></li>
<li><a href="/2010/01/12/faster-html-why-not/" rel="bookmark" title="Faster HTML! Why not?">Faster HTML! Why not? </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p><a href="/wp-content/uploads/2010/07/mails.jpg"><img src="/wp-content/uploads/2010/07/mails.jpg" alt="Zend_Mail" title="mails" width="430" height="276" class="aligncenter size-full wp-image-1822" srcset="/wp-content/uploads/2010/07/mails.jpg 430w, /wp-content/uploads/2010/07/mails-300x192.jpg 300w" sizes="(max-width: 430px) 100vw, 430px" /></a><br />
Typically you&#8217;d never like to send a non-html formatted mail from your web system. It&#8217;s ugly and it&#8217;s difficult to read. Instead of sending pure text, you&#8217;d like to add some images and styles. The way you can do it with Zend_Mail is simple enough. Replace the setBody method with setBodyHtml. Isn&#8217;t that natural?</p>
<pre lang="php">
// before
$mail = new Zend_Mail('utf-8');
$mail->setFrom('sender@example.com', 'Sender Name');
$mail->setBody('message in Html');
$mail->addTo('recipient@example.com', 'Recepient Name');
$mail->setSubject('Subject');
$mail->send();
</pre>
<pre lang="php">
// after
$mail = new Zend_Mail('utf-8');
$mail->setFrom('sender@example.com', 'Sender Name');
$mail->setBodyHtml('message in Html');
$mail->addTo('recipient@example.com', 'Recepient Name');
$mail->setSubject('Subject');
$mail->send();
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/03/25/send-mail-with-zend-framework/" rel="bookmark" title="Send Mail with Zend Framework">Send Mail with Zend Framework </a></li>
<li><a href="/2010/07/18/zend_mail-with-gmail/" rel="bookmark" title="Zend_Mail with GMail">Zend_Mail with GMail </a></li>
<li><a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" rel="bookmark" title="Send Authenticated POST Request with Zend_Http_Client">Send Authenticated POST Request with Zend_Http_Client </a></li>
<li><a href="/2010/01/12/faster-html-why-not/" rel="bookmark" title="Faster HTML! Why not?">Faster HTML! Why not? </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/07/17/send-html-mails-with-zend_mail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>document.forms[&#8216;myform&#8217;].submit() is not a function?</title>
		<link>/2010/07/05/document-formsmyform-submit-is-not-a-function/</link>
		<comments>/2010/07/05/document-formsmyform-submit-is-not-a-function/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 19:11:12 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1751</guid>
		<description><![CDATA[.submit() You want to submit the form by clicking on a link or some other element on the page and this is a simple task. You know that by simply adding something like document.forms[&#8216;the-form-name&#8217;].submit() this will work. Submit However you&#8217;d like to submit the form not only by clicking on that particular element, but also &#8230; <a href="/2010/07/05/document-formsmyform-submit-is-not-a-function/" class="more-link">Continue reading <span class="screen-reader-text">document.forms[&#8216;myform&#8217;].submit() is not a function?</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/25/detecting-post-requests-in-zend-framework/" rel="bookmark" title="Detecting POST Requests in Zend Framework">Detecting POST Requests in Zend Framework </a></li>
<li><a href="/2010/06/04/one-form-multiple-db-records/" rel="bookmark" title="One Form &#8211; Multiple DB Records">One Form &#8211; Multiple DB Records </a></li>
<li><a href="/2011/11/23/how-to-setup-different-error-messages-for-each-zend-form-element-validator/" rel="bookmark" title="How to Setup Different Error Messages for Each Zend Form Element Validator">How to Setup Different Error Messages for Each Zend Form Element Validator </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>.submit()</h2>
<p>You want to submit the form by clicking on a link or some other element on the page and this is a simple task. You know that by simply adding something like <strong>document.forms[&#8216;the-form-name&#8217;].submit()</strong> this will work.</p>
<pre lang="html4strict">
<form method="post" name="myform">
    <input type="text" name="user" />
    <a href="#" onclick="document.forms['myform'].submit();return false">Submit</a>
</form>
</pre>
<p>However you&#8217;d like to submit the form not only by clicking on that particular element, but also by clicking on the Enter while the focus is on a input field, and this wont work! That&#8217;s because you don&#8217;t have a input type=&#8221;submit&#8221;.</p>
<p>OK, first thing is to add a hidden input type=&#8221;submit&#8221; &#8211; than by clicking both on the Enter keyboard button and on the link with the onclick=&#8221;document.blah.blah.blah&#8221; will submit the form.</p>
<pre lang="html4strict">
<form method="post" name="myform">
    <input type="text" name="user" />
    <input type="submit" name="submit" value="submit" style="display:hidden" />
    <a href="#" onclick="document.forms['myform'].submit();return false">Submit</a>
</form>
</pre>
<h2>But this is not true!</h2>
<p>Than you&#8217;ll receive the following message:</p>
<pre>document.forms['myform'].submit() is not a function</pre>
<p>Why? This isn&#8217;t working, but ever line seems to be OK. The answer is &#8211; don&#8217;t name the input type=&#8221;submit&#8221; with the trivial &#8211; &#8220;submit&#8221;. Just give it another name:</p>
<pre lang="html4strict">
<form method="post" name="myform">
    <input type="text" name="user" />
    <input type="submit" name="something" value="something" style="display:hidden" />
    <a href="#" onclick="document.forms['myform'].submit();return false">Submit</a>
</form>
</pre>
<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/25/detecting-post-requests-in-zend-framework/" rel="bookmark" title="Detecting POST Requests in Zend Framework">Detecting POST Requests in Zend Framework </a></li>
<li><a href="/2010/06/04/one-form-multiple-db-records/" rel="bookmark" title="One Form &#8211; Multiple DB Records">One Form &#8211; Multiple DB Records </a></li>
<li><a href="/2011/11/23/how-to-setup-different-error-messages-for-each-zend-form-element-validator/" rel="bookmark" title="How to Setup Different Error Messages for Each Zend Form Element Validator">How to Setup Different Error Messages for Each Zend Form Element Validator </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/07/05/document-formsmyform-submit-is-not-a-function/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Send Authenticated POST Request with Zend_Http_Client</title>
		<link>/2010/06/28/send-authenticated-post-request-with-zend_http_client/</link>
		<comments>/2010/06/28/send-authenticated-post-request-with-zend_http_client/#respond</comments>
		<pubDate>Mon, 28 Jun 2010 19:01:44 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Computer networking]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Cross-site request forgery]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Hypertext Transfer Protocol]]></category>
		<category><![CDATA[Network protocols]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[Representational State Transfer]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1697</guid>
		<description><![CDATA[There is an easy way to send requests with Zend_Http_Client either in GET and POST. Actually you can request not only with GET and POST methods, but with any other http request method. $httpClient = new Zend_Http_Client('http://..../'); // request via post $response = $httpClient->request(Zend_Http_Client::POST); // or get $response = $httpClient->request(Zend_Http_Client::GET); However the interesting and useful &#8230; <a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" class="more-link">Continue reading <span class="screen-reader-text">Send Authenticated POST Request with Zend_Http_Client</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2011/04/13/post-with-zend_http_client/" rel="bookmark" title="POST with Zend_Http_Client">POST with Zend_Http_Client </a></li>
<li><a href="/2010/04/14/zend_http_client-and-case-sensitivity/" rel="bookmark" title="Zend_Http_Client and Case Sensitivity">Zend_Http_Client and Case Sensitivity </a></li>
<li><a href="/2010/03/23/read-remote-file-content-type-with-zend_http_client/" rel="bookmark" title="Read Remote File Content-Type with Zend_Http_Client">Read Remote File Content-Type with Zend_Http_Client </a></li>
<li><a href="/2010/03/25/send-mail-with-zend-framework/" rel="bookmark" title="Send Mail with Zend Framework">Send Mail with Zend Framework </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p><a href="/wp-content/uploads/2010/06/authentication.jpg"><img src="/wp-content/uploads/2010/06/authentication.jpg" alt="" title="authentication" width="300" height="230" class="aligncenter size-full wp-image-1716" /></a><br />
There is an easy way to send requests with <a title="Zend_Http_Client" href="http://framework.zend.com/manual/en/zend.http.client.html" target="_blank">Zend_Http_Client</a> either in GET and POST. Actually you can request not only with GET and POST methods, but with any other http request method.</p>
<pre lang="php">
$httpClient = new Zend_Http_Client('http://..../');
// request via post
$response = $httpClient->request(Zend_Http_Client::POST);
// or get
$response = $httpClient->request(Zend_Http_Client::GET);
</pre>
<p>However the interesting and useful thing is that you can perform authenticated requests:</p>
<pre lang="php">
$httpClient = new Zend_Http_Client('http://username:password@example.com/');
// or define it later
$httpClient = new Zend_Http_Client('http://example.com/');
$httpClient->setAuth('username', 'password');
</pre>
<p>That&#8217;s an opportunity to send/receive authenticated POST requests.</p>
<pre lang="php">
$httpClient = new Zend_Http_Client('http://username:password@example.com/');
// now post
$httpClient->request(Zend_Http_Client::POST);
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2011/04/13/post-with-zend_http_client/" rel="bookmark" title="POST with Zend_Http_Client">POST with Zend_Http_Client </a></li>
<li><a href="/2010/04/14/zend_http_client-and-case-sensitivity/" rel="bookmark" title="Zend_Http_Client and Case Sensitivity">Zend_Http_Client and Case Sensitivity </a></li>
<li><a href="/2010/03/23/read-remote-file-content-type-with-zend_http_client/" rel="bookmark" title="Read Remote File Content-Type with Zend_Http_Client">Read Remote File Content-Type with Zend_Http_Client </a></li>
<li><a href="/2010/03/25/send-mail-with-zend-framework/" rel="bookmark" title="Send Mail with Zend Framework">Send Mail with Zend Framework </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/06/28/send-authenticated-post-request-with-zend_http_client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Detecting Pressed Key with e.which in JavaScript</title>
		<link>/2010/06/02/detecting-pressed-key-with-e-which-in-javascript/</link>
		<comments>/2010/06/02/detecting-pressed-key-with-e-which-in-javascript/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 18:48:44 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[Human Interest]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Software engineering]]></category>

		<guid isPermaLink="false">/?p=1580</guid>
		<description><![CDATA[You have definitely decided to get which key has been pressed with JavaScript? This is very common when it comes to an Enter key press over a form element. Actually this should be automatically done by the browser, but when it comes to a default prevented form you&#8217;ve to check it for yourself. The job &#8230; <a href="/2010/06/02/detecting-pressed-key-with-e-which-in-javascript/" class="more-link">Continue reading <span class="screen-reader-text">Detecting Pressed Key with e.which in JavaScript</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/08/11/quick-look-at-javascript-objects/" rel="bookmark" title="Quick Look at JavaScript Objects">Quick Look at JavaScript Objects </a></li>
<li><a href="/2012/01/24/javascript-performance-for-vs-while/" rel="bookmark" title="JavaScript Performance: for vs. while">JavaScript Performance: for vs. while </a></li>
<li><a href="/2010/02/12/how-to-detect-a-variable-existence-in-javascript/" rel="bookmark" title="How to detect a variable existence in JavaScript?">How to detect a variable existence in JavaScript? </a></li>
<li><a href="/2010/05/24/javascript-objects-coding-style/" rel="bookmark" title="JavaScript Objects Coding Style">JavaScript Objects Coding Style </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>You have definitely decided to get which key has been pressed with JavaScript? This is very common when it comes to an Enter key press over a form element. Actually this should be automatically done by the browser, but when it comes to a default prevented form you&#8217;ve to check it for yourself.</p>
<p>The job can be done with a event&#8217;s which check. Let me show you some JavaScript/jQuery code:</p>
<pre lang="javascript">
$('.selector').click(function(e) {
	console.log(e.which);	
});
</pre>
<p>Note that this can be checked under Firefox and/or Safari like browsers which support the console object. This will give you the idea which key is pressed in a number value. The Enter is usually 13!<br />
If you don&#8217;t have such browser, you can replace that code with something like:</p>
<pre lang="javascript">
$('.selector').click(function(e) {
	alert(e.which);	
});
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/08/11/quick-look-at-javascript-objects/" rel="bookmark" title="Quick Look at JavaScript Objects">Quick Look at JavaScript Objects </a></li>
<li><a href="/2012/01/24/javascript-performance-for-vs-while/" rel="bookmark" title="JavaScript Performance: for vs. while">JavaScript Performance: for vs. while </a></li>
<li><a href="/2010/02/12/how-to-detect-a-variable-existence-in-javascript/" rel="bookmark" title="How to detect a variable existence in JavaScript?">How to detect a variable existence in JavaScript? </a></li>
<li><a href="/2010/05/24/javascript-objects-coding-style/" rel="bookmark" title="JavaScript Objects Coding Style">JavaScript Objects Coding Style </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/06/02/detecting-pressed-key-with-e-which-in-javascript/feed/</wfw:commentRss>
		<slash:comments>1</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>Inline Scripts with Zend_View_Helper_InlineScript</title>
		<link>/2010/04/27/inline-scripts-with-zend_view_helper_inlinescript/</link>
		<comments>/2010/04/27/inline-scripts-with-zend_view_helper_inlinescript/#respond</comments>
		<pubDate>Tue, 27 Apr 2010 15:27:59 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1506</guid>
		<description><![CDATA[Once I&#8217;ve posted about Zend Framework and script injections into the view of the app. However back than I didn&#8217;t mentioned the way the scripts can be injected on whatever place into the markup. This job&#8217;s done by Zend_View_Helper_InlineScript and that&#8217;s only an abstraction over the HeadScript. However thus the PHP code goes quite clean &#8230; <a href="/2010/04/27/inline-scripts-with-zend_view_helper_inlinescript/" class="more-link">Continue reading <span class="screen-reader-text">Inline Scripts with Zend_View_Helper_InlineScript</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/06/30/zend_view_helper_inlinescript-appends-scripts-twice/" rel="bookmark" title="Zend_View_Helper_InlineScript Appends Scripts Twice">Zend_View_Helper_InlineScript Appends Scripts Twice </a></li>
<li><a href="/2010/06/24/zend-framework-inject-javascript-code-in-a-actionview/" rel="bookmark" title="Zend Framework: Inject JavaScript Code in a Action/View">Zend Framework: Inject JavaScript Code in a Action/View </a></li>
<li><a href="/2010/06/23/bind-zend-action-with-non-default-view-part-2/" rel="bookmark" title="Bind Zend Action with Non-Default View &#8211; Part 2">Bind Zend Action with Non-Default View &#8211; Part 2 </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[<p>Once I&#8217;ve posted about Zend Framework and script injections into the view of the app. However back than I didn&#8217;t mentioned the way the scripts can be injected on whatever place into the markup. This job&#8217;s done by <a href="http://framework.zend.com/apidoc/core/Zend_View/Helper/Zend_View_Helper_InlineScript.html">Zend_View_Helper_InlineScript</a> and that&#8217;s only an abstraction over the HeadScript.</p>
<p>However thus the PHP code goes quite clean and maintainable.</p>
<pre lang="php">
$scripts = $this->view->inlineScript();
$scripts->appendFile('/scripts/production.js');
</pre>
<p>This is quite interesting because in the case of multiple scripts you can chain them into this:</p>
<pre lang="php">
$scripts = $this->view->inlineScript();
$scripts->appendFile('/scripts/production.js')
            ->appendFile('/scripts/development.js')
</pre>
<p>But that&#8217;s not everything. Although it looks very pretty and clean, PHP gives you the correct syntax of something like this:</p>
<pre lang="php">
$scripts = $this->view->inlineScript();
$scripts
            ->appendFile('/scripts/production.js')
            ->appendFile('/scripts/development.js')
</pre>
<p>And that&#8217;s particularly good when it comes to fast switching between production and development scripts includes.</p>
<pre lang="php">
$scripts = $this->view->inlineScript();
$scripts
 //        ->appendFile('/scripts/production.js')
            ->appendFile('/scripts/development.js')
</pre>
<p>You&#8217;d ask why I&#8217;d to comment my script includes. Because as it appears to be fashionable the JavaScripts are concatenated and compressed. This gives you performance benefits on the client side when downloading and executing the script. So it&#8217;s usual to have one compressed/minified and several development scripts. That&#8217;s why this commenting strategy is very useful.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/06/30/zend_view_helper_inlinescript-appends-scripts-twice/" rel="bookmark" title="Zend_View_Helper_InlineScript Appends Scripts Twice">Zend_View_Helper_InlineScript Appends Scripts Twice </a></li>
<li><a href="/2010/06/24/zend-framework-inject-javascript-code-in-a-actionview/" rel="bookmark" title="Zend Framework: Inject JavaScript Code in a Action/View">Zend Framework: Inject JavaScript Code in a Action/View </a></li>
<li><a href="/2010/06/23/bind-zend-action-with-non-default-view-part-2/" rel="bookmark" title="Bind Zend Action with Non-Default View &#8211; Part 2">Bind Zend Action with Non-Default View &#8211; Part 2 </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/04/27/inline-scripts-with-zend_view_helper_inlinescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Sanitize User Input in PHP?</title>
		<link>/2010/04/20/how-to-sanitize-user-input-in-php/</link>
		<comments>/2010/04/20/how-to-sanitize-user-input-in-php/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 12:03:26 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Markup languages]]></category>
		<category><![CDATA[Technical communication]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1461</guid>
		<description><![CDATA[It&#8217;s a question almost every PHP developer asks yourself. By me the most simple way to sanitize the user input is to save everything in the database with no loosing of tags or whatever HTML markup and than on displaying this on the client side to strip_tags if needed. In example when saving a HTML &#8230; <a href="/2010/04/20/how-to-sanitize-user-input-in-php/" class="more-link">Continue reading <span class="screen-reader-text">How to Sanitize User Input in PHP?</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<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/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/03/10/php-if-else-endif-statements/" rel="bookmark" title="PHP if-else-endif Statements">PHP if-else-endif Statements </a></li>
<li><a href="/2011/02/09/wanted-onfocusonblur-why-they-dont-work-always/" rel="bookmark" title="Wanted &#8211; onfocus/onblur. Why They Don&#8217;t Work Always!">Wanted &#8211; onfocus/onblur. Why They Don&#8217;t Work Always! </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s a question almost every PHP developer asks yourself. By me the most simple way to sanitize the user input is to save everything in the database with no loosing of tags or whatever HTML markup and than on displaying this on the client side to strip_tags if needed.</p>
<p>In example when saving a HTML formatted text you can use simply the htmlspecialchars method</p>
<pre lang="php">$description = htmlspecialchars($_POST['description']);</pre>
<p>Than you can be sure everything&#8217;s in the database, but it&#8217;s not actually HTML. Thus you don&#8217;t have any tags at all in the database field.</p>
<p>When you show this in the client side and you&#8217;d like to strip some tags, i.e. to keep only the &lt;a&gt; tag you can do this:</p>
<pre lang="php" escaped="true">echo strip_tags(htmlspecialchars_decode($description), '&lt;a&gt;');</pre>
<p>That&#8217;s the most simple way to keep everything as the original source. By me it&#8217;s better to keep whatever HTML markup there is on the input.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<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/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/03/10/php-if-else-endif-statements/" rel="bookmark" title="PHP if-else-endif Statements">PHP if-else-endif Statements </a></li>
<li><a href="/2011/02/09/wanted-onfocusonblur-why-they-dont-work-always/" rel="bookmark" title="Wanted &#8211; onfocus/onblur. Why They Don&#8217;t Work Always!">Wanted &#8211; onfocus/onblur. Why They Don&#8217;t Work Always! </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/04/20/how-to-sanitize-user-input-in-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>jQuery tips &#8211; storing data</title>
		<link>/2010/02/19/jquery-tips-storing-data/</link>
		<comments>/2010/02/19/jquery-tips-storing-data/#respond</comments>
		<pubDate>Fri, 19 Feb 2010 08:55:51 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[author]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Variable]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1125</guid>
		<description><![CDATA[Storing data? I was reading an article where the author says it is not a good practice to store data in the DOM. Indeed this is a bad practice and you should avoid it. After that he gives an example with using the DOM with the ALT attribute: $('selector').attr('alt', 'data being stored'); // later the &#8230; <a href="/2010/02/19/jquery-tips-storing-data/" class="more-link">Continue reading <span class="screen-reader-text">jQuery tips &#8211; storing data</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/03/31/jquery-get-the-id-of-the-current-element/" rel="bookmark" title="jQuery Get the Id of the Current Element">jQuery Get the Id of the Current Element </a></li>
<li><a href="/2010/02/24/storing-javascript-objects-in-html5-localstorage/" rel="bookmark" title="Storing JavaScript objects in html5 localStorage">Storing JavaScript objects in html5 localStorage </a></li>
<li><a href="/2010/09/27/jquery-setting-up-a-vector-path-fill-color/" rel="bookmark" title="jQuery: Setting Up a Vector Path Fill Color">jQuery: Setting Up a Vector Path Fill Color </a></li>
<li><a href="/2010/07/16/friday-algorithms-a-data-structure-javascript-stack/" rel="bookmark" title="Friday Algorithms: A Data Structure: JavaScript Stack">Friday Algorithms: A Data Structure: JavaScript Stack </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Storing data?</h2>
<p>I was reading an <a href="http://www.tripwiremagazine.com/2009/10/jquery-and-general-javascript-tips-to-improve-your-code.html" target="_blank">article</a> where the author says it is not a good practice to store data in the DOM. Indeed this is a bad practice and you should avoid it. After that he gives an example with using the DOM with the ALT attribute:</p>
<blockquote>
<pre>$('selector').attr('alt', 'data being stored');
// later the data can be retrieved using:
$('selector').attr('alt');</pre>
</blockquote>
<p>and after that the more clean:</p>
<blockquote>
<pre>$('selector').data('paramtername', 'data being stored');
// then later getting the data with
$('selector').data('paramtername');</pre>
</blockquote>
<p>OK, is more clean. But however it is bad practice to use such a &#8220;heavy&#8221; construction to store local data. It is obvious you can prefer to store it in a local variable. Thus you avoid the extra performance.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/03/31/jquery-get-the-id-of-the-current-element/" rel="bookmark" title="jQuery Get the Id of the Current Element">jQuery Get the Id of the Current Element </a></li>
<li><a href="/2010/02/24/storing-javascript-objects-in-html5-localstorage/" rel="bookmark" title="Storing JavaScript objects in html5 localStorage">Storing JavaScript objects in html5 localStorage </a></li>
<li><a href="/2010/09/27/jquery-setting-up-a-vector-path-fill-color/" rel="bookmark" title="jQuery: Setting Up a Vector Path Fill Color">jQuery: Setting Up a Vector Path Fill Color </a></li>
<li><a href="/2010/07/16/friday-algorithms-a-data-structure-javascript-stack/" rel="bookmark" title="Friday Algorithms: A Data Structure: JavaScript Stack">Friday Algorithms: A Data Structure: JavaScript Stack </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/02/19/jquery-tips-storing-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
