tag:blogger.com,1999:blog-2100928329644461483Sat, 22 Jun 2013 19:02:38 +0000javascript email validation regexdelete record in phpredirect in phpaccess different database outside wordpressjavascript email validation codejquery with ajaximplode function examplejson_decode exampleread excel fileJAVASCRIPTcontact formphp script for loginsession variables in phpphp contact formhow read data from urldownload files phpForm Validationjquery character countdowndelete selected checkbox phpphp database connectionredirectphp sessionscount characterphp tutorials for beginnersdownload a file in phpsimple jquery form validationphp dynamic menu tutorialdownload file in phpParsing XML in easy way using PHPnavigation barresize imageredirection in phpPassword encryption using MD5() functionimage resizing in phpmake dynamic menu phpsession phpdelete multiple recordsphp login authentication codejquery for divphp code to read csv filephp xml attribute parsingget extension from filename phpphp code for beginnersshow jquery effectform validation with jqueryjson_encode examplephp find files with extensionphp tutorialJQUERYcurl phpexamplephp login pageget character count in jquerycontact form phpstory of phpjavascript form validation script.preventing sql injectionphp header functionphp captcha scriptparsing xml in php examplephp captcha codedatabase php tutorialfile download with phpcontact forms in phpjavascript code for form validationphp code to send emailPHP Simple Login Formredirect in php with headercsv file reader in phpjquery ajax formwordpress connect to another databasejava script for validationphp redirectphp get file extension from stringcurl in phpMD5 function in phpfile download in php codefeedback form phpIntroduction To PHP mysqlsql injection examplehow to read content using curlJavaScript Email validation Using Regular Expressionhorizontal menuhow to delete multiple rows using checkbox in phpimplode function in phpjquery and ajaxjquery show hidephp session examplejquery form validationHow to use MD5() functionhow to redirectphp declare constantimagephp scriptshow to create dynamic menu in phpphp string functionsjavascript form validation tutorialexplode and implode function in phpconstant phpphp fast xml parsingphp session tutorial301 redirectresize image with phpWordPresstrim functionconstants in phpGenerate An Authentication Code in PHPphp jquery ajaxcontact form in phpEncrypt to MD5PHPexplode function phpdynamic menu in php from databasecontact form in htmldownload a php filejquery textarea character countmy sql databaseupload file in phphow to send mail in phpjquery form validation examplesimple login form in phpdownload file phpexplode function in phpphp simple dynamic menudeleting multiple rows with checkboxphp login formrandom code generatordefine constant in phpphp contact us form examplephp foreachphp login form codewhat is sql injection attackjson encode example in phpwhat is sql injection and how to preventphp trim spacesajax examplesauthentication code in phpremove spaces in stringsql injection attacksphp split file extensionphp captcha tutorialwordpress database on another serverupload filecaptcha for phpphp session variablephp mail scriptresize image phpor sql injectionphp captcha contact formtrim white spacecode to send email in phpphp constants examplewordpress access another databaseeffects of jqueryjson_decodejavascript form validation exampleIntroduction To PHPbasic of phpdynamic menu in phpphp explode function examplephp xml xmlreaderphp tutorialsjson encoding in phpphp constantsphp send mailphp captcha examplephp session functionsforeach loop in phpphp trim functionsjquery ajax examplesjquery ajax php examplecharacter count using jqueryphp file downloadphp xml parsing tutorialhistory of phpdefine constant phpcaptcha codejquery word countphp variablesphp constant scriptcheckbox jquery validationGet data from a URL using cURL PHPReading CSV file in phpphp login scriptjson encode and decode php javascript what is json302 redirectread content of url using curlredirect script in phpdefine constantjquery ajax tutorialphp image resizephp mail codeon show jquerywordpress access database phpcurl tutorialphp contact form scriptcode for image upload in phpparsing xml in php tutorialsession in phpimage resizerphp user login scriptphp database connectivityphp emptyabout phpabout sql injectiontrim function in phpjavascript form validation codeemail() funtion in phpajax in jquerycaptcha imageeasy form validationphp captchajavascript email validation scriptcheck a checkbox using jqueryeffects in jqueryxml parsercontact php formget uploaded file extension phpphp resize imageform validation in jqueryphp login codephp code to read filejquery ajax functionbest jquery form validationtext box character countjson_encodedelete multiple records examplevalidate form with multiple checkboxhow to connect database in phploops in phpjquery for validationimage resize in phpforeach loop in php arrayjson encoding and decoding in phpphp redirect codecaptcha in phpget extension of file in phpwhy phpRemove Wordpress Canonical Tagphp code for database connectionhow to generate authentication codedatabase connection in phpsend email via phpfile download phpbrief introduction to phplogin form examplemail server in phpcheckbox validation using jquerysql tutorialPHP Tutorial For BeginnersPHP Examples | Codeigniter | Jquery | Javascript | WordPresshttps://www.phptutorialforbeginners.com/[email protected] (Anil Gupta)Blogger38125tag:blogger.com,1999:blog-2100928329644461483.post-7325039103019217155Thu, 20 Jun 2013 10:49:00 +00002013-06-20T17:33:31.561+05:30PHPCreating a Search Engine in PHP and MySQL Or Creating Search Form in PHP MySQL | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><br /><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of&nbsp;PHP&nbsp;Tutorial for Beginners we will show how to create "<b>Search Engine in PHP with MySQL or how to create your Search Form in PHP by using MySQL"</b>.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><b><u>What is Search Engine</u>:-</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>Search Engine is a functionality where you enter your keywords or text in to search box, and it will give you all the record from database that matches your keyword.</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><b><u>In making Search Engine or Search Form you need to follow few steps</u>:-</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;">-&gt;Create a Database in phpmyadmin.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">-&gt;Create a Table called "main_article" in the Database.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">-&gt;In your table create fields called "article_entry_title" and enter some data in it which is used &nbsp;during search.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">-&gt;Now create config.php which have <a href="https://www.phptutorialforbeginners.com/2013/01/mysql-database-connection-in-php-php.html">database connection code</a>.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">-&gt;Last you have to create your script file for Search Engine.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"></span><br /><span style="font-family: Arial, Helvetica, sans-serif;">Now create the config.php file and put the following code in it. This file we will include in our search engine script for database connectivity.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>You can check the tutorial here for <a href="https://www.phptutorialforbeginners.com/2013/01/mysql-database-connection-in-php-php.html">Database connection in Php MySQL</a>.</b></span><br /><div class="code"><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">$database = "Php_Tutorial"; &nbsp;// the name of the database.</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">$server = "localhost"; &nbsp;// server to connect to.</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">$db_user = "root"; &nbsp;// mysql username to access the database with.</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">$db_pass = ""; &nbsp;// mysql password to access the database with.</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">$table = "users"; &nbsp; &nbsp;// the table that this script will set up and use.</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">$link = mysql_connect($server, $db_user, $db_pass);</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">mysql_select_db($database,$link);</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">?&gt;</span></div><br />Here is final script that will create your Search Engine page. Create search.php file and past the below code in it. <br /><div class="code"><span style="color: #cc0000;">&lt;html&gt;</span><br /><span style="color: #cc0000;">&lt;head&gt;</span><br /><span style="color: #cc0000;"><span style="white-space: pre;">&nbsp; </span>&lt;title&gt;Creating Search Engine page in php using mysql&lt;/title&gt;</span><br /><span style="color: #cc0000;">&lt;/head&gt;</span><br /><span style="color: #cc0000;">&lt;body&gt;</span><br /><span style="color: #cc0000;">&lt;form name="php search" action="&lt;?php $_SERVER['PHP_SELF'] ?&gt;" method="POST"&gt;</span><br /><span style="color: #cc0000;">&lt;label&gt;Enter Search Keyword:&lt;/label&gt;&lt;input type="text" name="search_keyword"&gt;</span><br /><span style="color: #cc0000;">&lt;input type="submit" value="Search"&gt;</span><br /><span style="color: #cc0000;">&lt;/form&gt;</span><br /><span style="color: #cc0000;">&lt;/body&gt;</span><br /><span style="color: #cc0000;">&lt;/html&gt;</span><br /><span style="color: #cc0000;"><br /></span><span style="color: #cc0000;">&lt;?php</span><br /><span style="color: #cc0000;">require 'config.php';</span><br /><span style="color: #cc0000;">//included database connection file</span><br /><span style="color: #cc0000;"><br /></span><span style="color: #cc0000;">if (isset($_POST['search_keyword']) &amp;&amp; !empty($_POST['search_keyword']))</span><br /><span style="color: #cc0000;">//Here we are checking Keyword is entered or not.</span><br /><span style="color: #cc0000;">{ </span><br /><span style="color: #cc0000;">$keyword = $_POST['search_keyword'];</span><br /><span style="color: #cc0000;">if(!empty($keyword))</span><br /><span style="color: #cc0000;">{</span><br /><span style="color: #cc0000;">$query ="SELECT * FROM main_article WHERE article_entry_title LIKE '%".mysql_real_escape_string($keyword)."%'";</span><br /><span style="color: #cc0000;"><br /></span><span style="color: #cc0000;">$query_result = mysql_query($query);</span><br /><span style="color: #cc0000;"><br /></span><span style="color: #cc0000;">$total_rows = mysql_num_rows($query_result);</span><br /><span style="color: #cc0000;">// We got the number of rows for matched keyword search</span><br /><span style="color: #cc0000;"><br /></span><span style="color: #cc0000;">if($total_rows&gt;0)</span><br /><span style="color: #cc0000;">{</span><br /><span style="color: #cc0000;">echo '&lt;b&gt;Total '.$total_rows.' records found for your searched keyword:&lt;br&gt;&lt;/b&gt;';</span><br /><span style="color: #cc0000;">$i=1;</span><br /><span style="color: #cc0000;">While($query_row = mysql_fetch_array($query_result))</span><br /><span style="color: #cc0000;">{</span><br /><span style="color: #cc0000;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo $i.'-'.$query_row['article_entry_title'].'&lt;br&gt;';</span><br /><span style="color: #cc0000;"><span class="Apple-tab-span" style="white-space: pre;"> </span>//Displaying each result line by line.</span><br /><span style="color: #cc0000;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$i++;</span><br /><span style="color: #cc0000;">}</span><br /><span style="color: #cc0000;">}</span><br /><span style="color: #cc0000;">else</span><br /><span style="color: #cc0000;">{</span><br /><span style="color: #cc0000;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo'No result found for your search query.';</span><br /><span style="color: #cc0000;">}</span><br /><span style="color: #cc0000;">}</span><br /><span style="color: #cc0000;">}</span><br /><span style="color: #cc0000;">else</span><br /><span style="color: #cc0000;">{</span><br /><span style="color: #cc0000;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo '&lt;b&gt;Please enter Keyword to search&lt;/b&gt;';</span><br /><span style="color: #cc0000;">}</span><br /><span style="color: #cc0000;">?&gt;</span><br /><span style="color: #cc0000;"><br /></span><br /><div></div></div></div>Your PHP Search Engine is now ready to use. Almost all user use the search engine in their website to easily search for the product which user require. You can modify it and use this search engine code in admin panel of your project for finding perticular entries.<br /><br /><b><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;<a href="https://www.phptutorialforbeginners.com/">Php Tutorial for Beginners</a>&nbsp;for more Codes.</span></b></div>https://www.phptutorialforbeginners.com/2013/06/creating-search-engine-in-php-and-mysql.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-6287257820774073906Wed, 19 Jun 2013 11:15:00 +00002013-06-19T18:20:33.557+05:30PHPMD5 function in phpHow to use MD5() functionEncrypt to MD5Password encryption using MD5() functionEncrypting Password using md5() function | PHP Tutorial for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif; font-size: large;"><b>MD5():-</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;">The MD5 message-digest algorithm is a widely used cryptographic hash function that produces a 128-bit (16-byte) hash value. MD5 has been utilized in a wide variety of security applications, and is also commonly used to check data integrity.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">In our case it calculet the md5 hash of given string. With the use of md5() you can make your login system more secure.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b><u>Here is the Syntax of MD5()</u>:-</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>$user_password="987654";</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>echo md5($user_password);</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b><u>Output</u> :-</b> <b>6c44e5cd17f0019c64b042e4a745412a</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;">It encrypt the string which we have provided.</span><br /><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>Example - Login Page</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">This is example of login page with encrypted password. You have also encrypt password during signup process else user will not able to login.</span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$user_name=$_POST['user_name'];</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$user_password=$_POST['user_password'];</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">// encrypting password</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$encrypted_password=md5($user_password);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$sql="SELECT * FROM $user_details WHERE username='$user_name' and password='$encrypted_password'";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$result=mysql_query($sql);</span><br /><div></div></div><b><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;<a href="https://www.phptutorialforbeginners.com/">Php Tutorial for Beginners</a>&nbsp;for more help.</span></b></div>https://www.phptutorialforbeginners.com/2013/06/encrypting-password-using-md5-function.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-2270047657454047488Mon, 10 Jun 2013 12:16:00 +00002013-06-19T17:42:26.455+05:30on show jqueryJQUERYeffects of jqueryjquery show hidejquery for diveffects in jqueryshow jquery effectjQuery show() and hide() Function | PHP Code for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will show you how to use jquery show() and hide() functions.</span><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">jQuery show() and hide() are the most common used functions. They are used to show or hide perticular element in the page.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b>show() – Display the matched elements.</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>hide() – Hide the matched elements.</b></span><br /><div><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div><div class="code"><div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;html&gt;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;head&gt;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;style type="text/css"&gt;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>div{</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>padding:8px;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>margin:10px;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>border:1px solid blue;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>width:450px;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>height:50px;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>background-color:blue;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>color:white;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/style&gt;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/head&gt;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;body&gt;</span></div><div></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;h1&gt;jQuery show() and hide() example&lt;/h1&gt;</span></div><div></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;div&gt;This is jquery show() and hide() example&lt;/div&gt;</span></div><div></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;button id=show_box&gt;show &lt;/button&gt;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;button id=hide_box&gt;hide&lt;/button&gt;</span></div><div></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;script type="text/javascript"&gt;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;$("#show_box").click(function () {</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &nbsp;$("div").show('fast');</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">});</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$("#hide_box").click(function () {</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &nbsp;$("div").hide('slow');</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">});</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$("#reset").click(function(){</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>location.reload();</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">});</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/script&gt;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/body&gt;</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/html&gt;</span></div></div></div><b><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;<a href="http://www.phpcodeforbeginner.blogspot.in/">Php Tutorials for Beginners</a>&nbsp;for more help.</span></b></div>https://www.phptutorialforbeginners.com/2013/06/jquery-show-and-hide-function-php-code.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-7618501371063620179Sun, 09 Jun 2013 06:47:00 +00002013-06-19T17:29:31.943+05:30sql injection examplewhat is sql injection attacksql tutorialabout sql injectionsql injection attackspreventing sql injectionwhat is sql injection and how to preventor sql injectionWordPressPreventing SQL Injection | PHP Code For Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:RelyOnVML/> <o:AllowPNG/> </o:OfficeDocumentSettings></xml><![endif]--><br /><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:DontVertAlignCellWithSp/> <w:DontBreakConstrainedForcedTables/> <w:DontVertAlignInTxbx/> <w:Word11KerningPairs/> <w:CachedColBalance/> </w:Compatibility> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument></xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false" UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles></xml><![endif]--><!--[if gte mso 10]><style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} </style><![endif]--> <br /><div class="MsoNormal"></div><div class="MsoNormal">If you are spent any serious time developing Web Application, you know the risk of SQL injection. Sql injection is caused when data is inserted into database that hasn’t been properly sanitized. For example, a simple demonstration of SQL injection would be an exploit that give a malicious person administration access to your site.</div><div class="MsoNormal"><br /></div><div class="MsoNormal">Say you have an HTML form that requires a username and password. Each of these form fields are named “user” and “pass”, respectively. On backend, the authentication mechanism checks the username and password against the database like this:</div><div class="MsoNormal"><b>SELECT * FROM usertable WHERE username = ‘$user’ AND password = ‘$pass’;</b></div><div class="MsoNormal"><br /></div><div class="MsoNormal">If form data is unsanitized but the user actually inputs proper username and password, then the SQL query works and authentication is granted. However, if someone enters a more malicious string, they can wreak havoc on your system. For example, if user entered a username of user ’OR 1=1;-- and any password then SQL will also be valid and will give the user access to the protected system. The query would actually be run is shown here:</div><div class="MsoNormal"><b>SELECT * FROM usertable WHERE username = ‘user’ OR 1=1;--random password</b></div><div class="MsoNormal"><br /></div><div class="MsoNormal">To understand the practical danger in this query, you have to understand that two dashes (--) is equivalent to the comment. Everything after he – is ignored by MySQL so it doesn’t matter if invalid password is provided. Also, because you haven’t “escaped” the single quote in the username, the single quote becomes the “end” of the value being checked against the username field. Though this is properly invalid as well, it doesn’t matter because the attack adds an OR 1=1 (which is always true) into the query. The query read, “Retrieve the record from usertable where username is ‘user’ or 1=1.” Because 1 is always equals to 1, the SQL always evaluates as true and attacker can access the protected resources or application.</div><div class="MsoNormal"><br /></div><div class="MsoNormal">To prevent against a possible SQL injection attack, the WordPress database class provides the $wpdb-&gt;prepare () method. It handles data sanitization of SQL statements to prevent against SQL injection,as show in below example. Note that instead of using %d to indicate a numerical replacement, you could use %1$d syntax to indicate, “replace this placeholder with the first replacement value in the format of a number.”</div><div class="MsoNormal"><br /></div><div class="MsoNormal"><b style="mso-bidi-font-weight: normal;">Using the prepare () method to sanitize SQL against SQL Injection attacks.</b></div><div class="code"><div class="MsoNormal">$sanitized_sql = $wpdb-&gt;prepare (“’INSERT INTO my_plugin_table SET field1 = %1$d, field2 = %2$s, field3 = %3$s’, 13, ‘Php code’, ‘Wordpress’);</div><div class="MsoNormal">$wpdb-&gt;query ($sanitized_sql);</div></div><div class="MsoNormal"><br /></div></div>https://www.phptutorialforbeginners.com/2013/06/preventing-sql-injection-php-code-for.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-8239529934692903581Tue, 16 Apr 2013 09:32:00 +00002013-04-16T15:05:36.820+05:30PHPget uploaded file extension phpget extension of file in phpphp get file extension from stringphp find files with extensionget extension from filename phpphp split file extensionReading extension of uploaded file in php | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will show you how to fetch or read the extension of currently uploaded file.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">There are two simple way to read the extension of file, one is by using the php string function and another is by user of fileinfo() function. Following example will show you the both way to read the extension of file.</span> <br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">1) $file_extension = strtolower(substr(strrchr($FILES['image']['name'],"."),1));&nbsp;</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">2) $file_extension = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION);</span></span></div><span style="font-family: Arial, Helvetica, sans-serif;"><b>By use of any of above code you will be able to read or get the extention any file.</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><b><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;<a href="http://www.phpcodeforbeginner.blogspot.in/">Php Tutorials for Beginners</a>&nbsp;for more help.</span></b></div>https://www.phptutorialforbeginners.com/2013/04/reading-extension-of-uploaded-file-in.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-7752416681682945060Tue, 16 Apr 2013 05:46:00 +00002013-04-16T11:16:10.819+05:30download a php filePHPphp file downloaddownload files phpdownload file in phpdownload file phpfile download with phpfile download phpfile download in php codedownload a file in phpFile Download Script in Php | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will show you how to download any files from web server to local machine. When you want to download any file you need to send the file name to this application.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><b><u>Step 1</u>:-</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>Create index.html or any name for file and put the code in it. This is the html cede in which download link to the file is available. In download link pass the file name as query string. In bellow code "download.php" is the file where file downloading code is present. We are passing the file name of corresponding file which is to be downloaded.</b></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;html&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;head&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;title&gt;File download in php&lt;/title&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/head&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;body&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;table&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;tr&gt;&lt;td&gt;&lt;a href="download.php?file=download_file_in_php.jpg" class="links"&gt;Download file in php&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;tr&gt;&lt;td&gt;&lt;a href="download.php?file=file_download.pdf" class="links"&gt;Download pdf&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/table&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/body&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/html&gt;</span></div><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><b><u>Step 2</u>:-</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>Copy this code in a file and save it as "download.php". In above step when we click on link it will call the download.php file which is bellow. The bellow code recieve the file name which was sent in query string and process for downloading it.&nbsp;</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">set_time_limit(0);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">//path to the file.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">//Your file should be in this folder only.</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$file_path='files/'.$_REQUEST['file'];</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">//Call the download function with file path,file name and file type</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">download_file($file_path, ''.$_REQUEST['file'].'', 'text/plain');</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">function download_file($file, $name, $mime_type='')</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">{</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;if(!is_readable($file)) die('File not found.');</span><br /><span style="color: red;"><br /></span><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;$size = filesize($file);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;$name = rawurldecode($name);</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp;$known_mime_types=array(</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;<span class="Apple-tab-span" style="white-space: pre;"> </span>"pdf" =&gt; "application/pdf",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;<span class="Apple-tab-span" style="white-space: pre;"> </span>"txt" =&gt; "text/plain",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;<span class="Apple-tab-span" style="white-space: pre;"> </span>"html" =&gt; "text/html",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;<span class="Apple-tab-span" style="white-space: pre;"> </span>"htm" =&gt; "text/html",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"exe" =&gt; "application/octet-stream",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"zip" =&gt; "application/zip",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"doc" =&gt; "application/msword",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"xls" =&gt; "application/vnd.ms-excel",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"ppt" =&gt; "application/vnd.ms-powerpoint",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"gif" =&gt; "image/gif",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"png" =&gt; "image/png",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"jpeg"=&gt; "image/jpg",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"jpg" =&gt; &nbsp;"image/jpg",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"php" =&gt; "text/plain"</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;);</span><br /><span style="color: red;"><br /></span><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;if($mime_type==''){</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> $file_extension = strtolower(substr(strrchr($file,"."),1));</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> if(array_key_exists($file_extension, $known_mime_types)){</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$mime_type=$known_mime_types[$file_extension];</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> } else {</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$mime_type="application/force-download";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> };</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;};</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp;@ob_end_clean();&nbsp;</span></span><br /><span style="color: red;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp;// required for IE, otherwise Content-Disposition may be ignored</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;if(ini_get('zlib.output_compression'))</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; ini_set('zlib.output_compression', 'Off');</span><br /><span style="color: red;"><br /></span><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;header('Content-Type: ' . $mime_type);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;header('Content-Disposition: attachment; file="'.$name.'"');</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;header("Content-Transfer-Encoding: binary");</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;header('Accept-Ranges: bytes');</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;header("Cache-control: private");</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;header('Pragma: private');</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;readfile($file);&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span></div><div><b><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;<a href="http://www.phpcodeforbeginner.blogspot.in/">Php Tutorials for Beginners</a>&nbsp;for more help.</span></b></div></div>https://www.phptutorialforbeginners.com/2013/04/file-download-script-in-php-php.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-5935087293055951365Mon, 15 Apr 2013 13:17:00 +00002013-04-16T10:05:48.102+05:30resize image phpupload file in phpPHPimageresize image with phpimage resizing in phpimage resizerimage resize in phpresize imagephp image resizecode for image upload in phpphp resize imageResize Image or Crop image Using GD Library in Php | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;">Image resize or image&nbsp;cropping&nbsp;is one of the important part during any website building. To make our uploaded image fix exactly in same diamention in&nbsp;front end&nbsp;we need to resize or crop that image.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of Php code for beginners we will show you the example of code which resize the uploaded image using GD library.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>This is the html code for uploading the image for resizing. After selecting image you will click on submit button. When submit button will click our next code will check for image and prosess them accordingly.</b></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;html&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;head&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;title&gt;Resize image in php&lt;/title&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/head&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;body&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;&lt;form name = "form" action = "&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method = "POST" enctype="multipart/form-data"&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;table&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;&lt;label&gt;Insert Image to resize:-&lt;/label&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;&lt;input type = "file" name = "file" id = "file"&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td colspan = 2&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;input type = "submit" value = "submit" name = "submit"&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/table&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;&lt;/form&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/body&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/html&gt;</span></div><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>Now when you click on submit our php code check whether submit button is clicked or not? As soon as he find submit is clicked the following code run to prosses the image for resizing.&nbsp;</b></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">if(isset($_POST['submit'])){</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$error = 0;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$uploadfile = 'images/'.basename($_FILES['file']['name']);</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="color: red; white-space: pre;"> </span>// $uploadfile is directory name where original image will save. You can unlink it after resizing the image.</span><br /><span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$resize = &nbsp;'resize/';</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="color: red; white-space: pre;"> </span>//It is you resize image directory.</span><br /><span class="Apple-tab-span" style="white-space: pre;"><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$file_name = basename($_FILES['file']['name']);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$filecheck = basename($_FILES['file']['name']);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$ext = strtolower(substr($filecheck, strrpos($filecheck, '.') + 1));</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if (!(($ext == "jpg" || $ext == "gif" || $ext == "png") &amp;&amp; ($_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/png") &amp;&amp; ($_FILES["file"]["size"] &lt; 2120000))){</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo "File Not Supported";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$error = 1;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>die();</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="color: red; white-space: pre;"> </span>// In above code we are checking the type and size of image. If it is not image file the error messege will appear.</span><br /><span class="Apple-tab-span" style="white-space: pre;"><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if($_FILES['file']['name']!="")</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>ini_set('memory_limit','32M');</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="color: red; white-space: pre;"> </span>//Here we set the memory limit.</span><br /><span class="Apple-tab-span" style="white-space: pre;"><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile))&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo $message= "Error in uploading a file due to the size of image.\n";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$error = 1;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>else&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$info = pathinfo($uploadfile);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$img = imagecreatefromjpeg( $uploadfile );</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$width = imagesx( $img );</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$height = imagesy( $img );</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$new_width = 100; </span><span style="font-family: Arial, Helvetica, sans-serif;">//New Width for Image.</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$new_height = 100; </span><span style="font-family: Arial, Helvetica, sans-serif;">//New Height for Image</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$tmp_img = imagecreatetruecolor( $new_width, $new_height );</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>imagejpeg( $tmp_img, "{$resize}{$file_name}" );</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="color: red; white-space: pre;"> </span>// All processing is done and your resized image will store from temporary directory to your resize image directory</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">if($error==0)&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">{</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; echo "Image Uploaded Successfully.";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; exit;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">}<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">} &nbsp; &nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b>Here is the Complete code for you to resize you image according to the height width set by you.</b></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">if(isset($_POST['submit'])){</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$error = 0;</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$uploadfile = 'images/'.basename($_FILES['file']['name']);</span><span style="font-family: Arial, Helvetica, sans-serif; white-space: pre;"> </span></span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$resize = &nbsp;'resize/';</span><span style="font-family: Arial, Helvetica, sans-serif; white-space: pre;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$file_name = basename($_FILES['file']['name']);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$filecheck = basename($_FILES['file']['name']);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$ext = strtolower(substr($filecheck, strrpos($filecheck, '.') + 1));</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if (!(($ext == "jpg" || $ext == "gif" || $ext == "png") &amp;&amp; ($_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/png") &amp;&amp; ($_FILES["file"]["size"] &lt; 2120000))){</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo "File Not Supported";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$error = 1;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>die();</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif; white-space: pre;"> </span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if($_FILES['file']['name']!="")</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>ini_set('memory_limit','32M');</span><br /><span class="Apple-tab-span" style="white-space: pre;"><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile))&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo $message= "Error in uploading a file due to the size of image.\n";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$error = 1;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>else&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$info = pathinfo($uploadfile);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$img = imagecreatefromjpeg( $uploadfile );</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$width = imagesx( $img );</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$height = imagesy( $img );</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$new_width = 100;&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$new_height = 100;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$tmp_img = imagecreatetruecolor( $new_width, $new_height );</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, &nbsp; &nbsp; $width, $height );</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>imagejpeg( $tmp_img, "{$resize}{$file_name}" );</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">if($error==0)&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">{</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; echo "Image Uploaded Successfully.";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; exit;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">}<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">} &nbsp; &nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;html&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;head&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;title&gt;Resize image in php&lt;/title&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/head&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;body&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;&lt;form name = "form" action = "&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method = "POST" enctype="multipart/form-data"&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;table&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;&lt;label&gt;Insert Image to resize:-&lt;/label&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;&lt;input type = "file" name = "file" id = "file"&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td colspan = 2&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;input type = "submit" value = "submit" name = "submit"&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/table&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp;&lt;/form&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/body&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/html&gt;</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b>Hope this php tutorial is useful for you. Keep following <a href="http://www.phpcodeforbeginner.blogspot.in/">www.phpcodeforbeginner.blogspot.in</a> for more help.</b></span><br /><br /></div>https://www.phptutorialforbeginners.com/2013/04/resize-image-or-crop-image-using-gd.html[email protected] (Anil Gupta)4tag:blogger.com,1999:blog-2100928329644461483.post-8453018908177003491Wed, 03 Apr 2013 13:33:00 +00002013-04-11T18:14:37.203+05:30get character count in jqueryjquery word countjquery character countdownJQUERYtext box character countcount characterjquery textarea character countcharacter count using jqueryCharacter Count in Jquery | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will show you example how to count character of text field using jquery.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;html&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &lt;head&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &nbsp; &lt;script src="http://code.jquery.com/jquery-1.5.js"&gt;&lt;/script&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &nbsp; &lt;script&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &nbsp; &nbsp; function countCharacter(input) {</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var len = input.value.length;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$('#charcount').text('Character Count :- '+len);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp; }</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &nbsp; &lt;/script&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &lt;/head&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &lt;body&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &nbsp; &lt;textarea id="desc" onkeyup="countCharacter(this)"&gt;&lt;/textarea&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &nbsp; &lt;div id="charcount"&gt;&lt;/div&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &lt;/body&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/html&gt;</span><br /></div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;</span><a href="http://www.phpcodeforbeginner.blogspot.in/" style="font-family: Arial, Helvetica, sans-serif;">www.phpcodeforbeginner.blogspot.in</a><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp;for more help.</span></div>https://www.phptutorialforbeginners.com/2013/04/character-count-in-jquery-php-tutorials.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-7028830590608884322Fri, 22 Mar 2013 17:23:00 +00002013-04-11T18:11:03.170+05:30wordpress connect to another databasewordpress access database phpwordpress database on another serverwordpress access another databaseaccess different database outside wordpressWordPressAccess Another Database in WordPress Or Get Data of Another Database in WordPress<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial,Helvetica,sans-serif;">In wordpress we usually use the database which we have configured in "wp-config" file and access them using global $wpdb variable. But when situation arise and we require to get data from another database then $wpdb variable will not work.<br /><br />In this tutorial of php code for beginners we will show you how to access another database or fetch data from another database in WordPress.<br /><br /><b>To access another database first step is to write down the following code in your theme's function.php file or respective plugin file.</b></span><br /><div class="code"><span style="color: red;"><span style="font-family: Arial,Helvetica,sans-serif;">$mydb = new wpdb($DB_USER, $DB_PASSWORD, $DB_NAME, $DB_HOST);</span></span><br /><span style="color: red;"><span style="font-family: Arial,Helvetica,sans-serif;">$mydb-&gt;show_errors();</span></span><br /></div><span style="font-family: Arial,Helvetica,sans-serif;"><b>In above step you have created a variable called "$mydb". Now with the use of this variable you can access the data of your database specified above in any file.</b><br /><br />Example:-</span><br /><div class="code"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;">&lt;?php</span></span><br /><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;">global $mydb; // Don't forget to initialize this</span></span><br /><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;">$sql="SELECT * FROM customer";</span></span><br /><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;">$result =&nbsp; $newdb-&gt;get_results($sql);</span></span><br /><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;">foreach($result as $cust_record)</span></span><br /><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;">{</span></span><br /><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;">&nbsp;&nbsp;&nbsp; echo $cust_record-&gt;name;</span></span><br /><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;">}</span></span><br /><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;">?&gt;</span></span></div><span style="font-family: Arial,Helvetica,sans-serif;"></span></div>https://www.phptutorialforbeginners.com/2013/03/access-another-database-in-wordpress-or.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-6059763608677626812Thu, 21 Mar 2013 08:19:00 +00002013-04-11T18:06:40.828+05:30PHPhow to delete multiple rows using checkbox in phpdelete selected checkbox phpdelete multiple records exampledelete multiple recordsdeleting multiple rows with checkboxdelete record in phpDelete Multiple Records Using Checkboxes in Php | PHP Tutorials for beginners <div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will show you how to delete multiple records using checkboxes.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;script&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">jQuery(function($) {</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$("form input[id='check_all']").click(function() { // triggred check</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>var inputs = $("form input[type='checkbox']"); // get the checkbox</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>for(var i = 0; i &lt; inputs.length; i++) { // count input tag in the form</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>var type = inputs[i].getAttribute("type"); // &nbsp;get the type attribute</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if(type == "checkbox") {</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if(this.checked) {</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>inputs[i].checked = true; // checked</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>} else {</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>inputs[i].checked = false; // unchecked</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> }</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>});</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$("form input[id='delete']").click(function() { &nbsp;// triggred submit</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>var count_checked = $("[name='checkbox[]']:checked").length; // count the checked</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if(count_checked == 0) {</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>alert("Please select a product(s) to delete.");</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return false;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if(count_checked == 1) {</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return confirm("Are you sure you want to delete these product?");</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>} else {</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return confirm("Are you sure you want to delete these products?");</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> &nbsp;}</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>});</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">}); // jquery end</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&lt;/script&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$host="localhost";&nbsp;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$username="root";&nbsp;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$password="";&nbsp;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$db_name="practice";&nbsp;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$tbl_name="test";</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">mysql_connect("$host", "$username", "$password")or die("cannot connect");&nbsp;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">mysql_select_db("$db_name")or die("cannot select DB");</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">$sql="SELECT * FROM $tbl_name";</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$result=mysql_query($sql);</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">$count=mysql_num_rows($result);</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">?&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&lt;table width="400" border="0" cellspacing="1" cellpadding="0"&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;tr&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&lt;form name="form1" method="post" action=""&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;tr&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&amp;nbsp;&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&lt;strong&gt;Delete multiple rows in mysql&lt;/strong&gt; &lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;/tr&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;tr&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;Check All &lt;input type="checkbox" id="check_all" value=""&gt;&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&lt;strong&gt;Id&lt;/strong&gt;&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&lt;strong&gt;Name&lt;/strong&gt;&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&lt;strong&gt;Lastname&lt;/strong&gt;&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&lt;strong&gt;Email&lt;/strong&gt;&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&lt;/tr&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">while($rows=mysql_fetch_array($result)){</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">?&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&lt;tr&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&lt;input name="checkbox[]" type="checkbox" id="checkbox[]" value="&lt;? echo $rows['id']; ?&gt;"&gt;&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&lt;? echo $rows['id']; ?&gt;&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&lt;? echo $rows['name']; ?&gt;&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&lt;? echo $rows['lastname']; ?&gt;&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&lt;? echo $rows['email']; ?&gt;&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;/tr&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">}</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">?&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&lt;tr&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;td&gt;&lt;input name="delete" type="submit" id="delete" value="Delete"&gt;&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;/tr&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">// Check if delete button active, start this&nbsp;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">if(isset($_POST['delete'])){</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">for($i=0;$i&lt;count($_POST['checkbox']);$i++){</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$del_id=$_POST['checkbox'][$i];</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$sql = "DELETE FROM $tbl_name WHERE id='$del_id'";</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$result = mysql_query($sql);</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">}</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">// if successful redirect to delete_multiple.php&nbsp;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">if($result){</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">echo "&lt;meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\"&gt;";</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">}</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">}</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">mysql_close();</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">?&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&lt;/table&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;/form&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;/td&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;/tr&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">&lt;/table&gt;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;<a href="http://www.phpcodeforbeginner.blogspot.in/">www.phpcodeforbeginner.blogspot.in</a><span id="goog_1585376968"></span><span id="goog_1585376969"></span><a href="http://www.blogger.com/"></a>&nbsp;for more examples.</span></div>https://www.phptutorialforbeginners.com/2013/03/delete-multiple-records-using.html[email protected] (Anil Gupta)1tag:blogger.com,1999:blog-2100928329644461483.post-5900259095308595177Tue, 12 Mar 2013 11:45:00 +00002013-03-19T18:30:01.750+05:30WordPressInserting Data to Custom Table in WordPress | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><br /><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will show you how to insert data to custom table in WordPress</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">We are using&nbsp;different&nbsp;table of&nbsp;WordPress&nbsp;to fetch or store data. But some time during customization we need to create our own table in our&nbsp;WordPress&nbsp;database and store or fetch data from it.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">For&nbsp;WordPress&nbsp;expert it very simple thing but for beginners it took time to R&amp;d on this. So I thought make it simple and show you the simple step to add your data in your custom table of&nbsp;WordPress.</span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">global $wpdb;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$wpdb-&gt;my_custom_table = 'my_custom_table';<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;">$query = $wpdb-&gt;prepare("</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>INSERT INTO $wpdb-&gt;my_custom_table</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>(id, name, date)</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>VALUES ('','Neel','$date')</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>");</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$results = $wpdb-&gt;query($query);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span></div><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following <a href="http://www.phpcodeforbeginner.blogspot.in/">PHP Tutorials for Beginners</a></span><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp;for more help.</span></div>https://www.phptutorialforbeginners.com/2013/03/inserting-data-to-custom-table-in.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-3298504136835514439Thu, 07 Mar 2013 10:15:00 +00002013-03-26T15:19:05.283+05:30constants in phpphp constant scriptPHPdefine constantphp tutorialsdefine constant in phpphp constants exampleconstant phpphp declare constantphp constantsdefine constant phpDefine Constants in Php | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><br /><b><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><u>What is Constant</u>:-</span></b><br /><span style="font-family: Arial, Helvetica, sans-serif;">A constant is an identifier for a any value. Constant is case-sensitiv and constant identifiers are always uppercase. A constant name always starts with a letter or underscore. A constant value cannot change during the execution of the script. If we have defined a constant, it can never be changed.&nbsp;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><b><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><u>How to define Constant</u>:-</span></b><br /><span style="font-family: Arial, Helvetica, sans-serif;">To define a constant we have to use define() function and to retrieve the value of a constant, we have to use its name. Unlike &nbsp;variables constants do not have $ sign.</span><br /><div class="code"><br /><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>define("PAGE_TITLE", "PHP Tutorials for Beginners");</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>define("DESC", "Php constant tutorial example");</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo PAGE_TITLE; <span class="Apple-tab-span" style="white-space: pre;"> </span>// Output:- PHP Tutorials for Beginners</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo DESC; <span class="Apple-tab-span" style="white-space: pre;"> </span>// Output:- Php constant tutorial example</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span><br /><br /></div><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><b><u>Differences between constants and variables are</u>:-</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;">There is no need to write a dollar sign ($) before a constant, where as in Variable one has to write a dollar sign.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">Constants cannot be defined by simple assignment, they may only be defined using the define() function.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">Constants may be defined and accessed anywhere without regard to variable scoping rules.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">Once the Constants have been set, may not be redefined or undefined.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;</span><a href="http://www.phpcodeforbeginner.blogspot.in/" style="font-family: Arial, Helvetica, sans-serif;">www.phpcodeforbeginner.blogspot.in</a><span id="goog_1585376968" style="font-family: Arial, Helvetica, sans-serif;"></span><span id="goog_1585376969" style="font-family: Arial, Helvetica, sans-serif;"></span><a href="http://www.blogger.com/" style="font-family: Arial, Helvetica, sans-serif;"></a><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp;for more examples.</span></div>https://www.phptutorialforbeginners.com/2013/03/define-constants-in-php-php-tutorials.html[email protected] (Anil Gupta)2tag:blogger.com,1999:blog-2100928329644461483.post-4801620005595869737Thu, 07 Mar 2013 07:00:00 +00002013-03-08T09:57:17.768+05:30WordPressShowing the Posts of Perticular Category in WordPress | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will show you how to show the posts of perticular category in WordPress</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">The below code will show only posts of category id 1.</span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;ul&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">global $post;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$args = array('category' =&gt; 1);<span class="Apple-tab-span" style="white-space: pre;"> </span>//specify category ID</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$selectedposts = get_posts( $args );</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">foreach( $selectedposts as $post ) :<span class="Apple-tab-span" style="white-space: pre;"> </span>setup_postdata($post); ?&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php endforeach; wp_reset_postdata(); ?&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/ul&gt;</span></div><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;</span><a href="http://www.phpcodeforbeginner.blogspot.in/" style="font-family: Arial, Helvetica, sans-serif;">www.phpcodeforbeginner.blogspot.in</a><span id="goog_1585376968" style="font-family: Arial, Helvetica, sans-serif;"></span><span id="goog_1585376969" style="font-family: Arial, Helvetica, sans-serif;"></span><a href="http://www.blogger.com/" style="font-family: Arial, Helvetica, sans-serif;"></a><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp;for more help.</span></div>https://www.phptutorialforbeginners.com/2013/03/showing-posts-of-perticular-category-in.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-9148925621440313073Thu, 07 Mar 2013 05:18:00 +00002013-03-08T09:57:30.911+05:30Remove Wordpress Canonical TagWordPressRemove Default Canonical Tag from WordPress Pages or Posts | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will show you how to remove the in built canonical tag from&nbsp;WordPress&nbsp;pages or posts.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Whenever we create any post in&nbsp;WordPress&nbsp;and publish it,&nbsp;WordPress&nbsp;automatically create the canonical tag for that url. The canonical tag src show the same url which you have created for that post. You can check this from the source code of the page.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">If you don't want&nbsp;WordPress&nbsp;to create the canonical tag and want to use some other canonical tag from any plugin then you need to do this small changes in your&nbsp;WordPress&nbsp;"function.php" file.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Just put the below code in your function.php file and you problem is solved.</span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">remove_action(‘wp_head’, ‘rel_canonical’);</span></div><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;<a href="http://www.phpcodeforbeginner.blogspot.in/">www.phpcodeforbeginner.blogspot.in</a><span id="goog_1585376968"></span><span id="goog_1585376969"></span><a href="http://www.blogger.com/"></a>&nbsp;for more help.</span></div>https://www.phptutorialforbeginners.com/2013/03/remove-default-canonical-tag-from.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-7207470385868622929Wed, 06 Mar 2013 10:50:00 +00002013-03-07T13:46:01.125+05:30php captcha tutorialcaptcha for phpPHPphp captcha examplephp captchaphp captcha codephp scriptsphp captcha scriptcaptcha in phpphp tutorialphp captcha contact formcaptcha imagecaptcha codeCreate Your Own Captcha in Php or Create Feedback Form with Captcha | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><br /><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will see how to create your own capcha for your feedback, registration or any other form.</span><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-YLmbs3urCps/UTce1X6a4lI/AAAAAAAAAGY/2AMk5_7vdT8/s1600/feedback.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Php captcha" border="0" height="256" src="http://4.bp.blogspot.com/-YLmbs3urCps/UTce1X6a4lI/AAAAAAAAAGY/2AMk5_7vdT8/s320/feedback.JPG" title="Feedback form with Captcha" width="320" /></a></div><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b><u><span style="color: blue;">Step 1</span></u>:-</b> Create captcha.php file and add the below code in it.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>Note: Create a fonts folder in your root directory and add "arial.ttf" file. You can find arial.ttf in you system's font folder.</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">session_start();</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$string = '';</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">for ($i = 0; $i &lt; 5; $i++) {</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$string .= chr(rand(97, 122));</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$_SESSION['captcha'] = $string;</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">$font_path = 'fonts/';</span></span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">$captcha_image = imagecreatetruecolor(150, 60);</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$text_color = imagecolorallocate($captcha_image, 200, 100, 90); // red</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$bg_color = imagecolorallocate($captcha_image, 255, 255, 255);</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">imagefilledrectangle($captcha_image,0,0,399,99,$bg_color);</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">imagettftext ($captcha_image, 30, 0, 10, 40, $text_color, $font_path."arial.ttf", $_SESSION['captcha']);</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">header("Content-type: image/png");</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">imagepng($captcha_image);</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;">?&gt;</span></span></div><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b><u><span style="color: blue;">Step 2</span></u>:-</b> Now create feedback.php and past the following code in it.</span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">session_start();</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">if(isset($_POST['submit'])) {</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if(!empty($_POST['name']) &amp;&amp; !empty($_POST['email']) &amp;&amp; !empty($_POST['message']) &amp;&amp; !empty($_POST['code'])) {</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if($_POST['code'] == $_SESSION['captcha']) {</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>// send email to admin</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$accept = "Thank you for your feedback.";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>} else {</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$error = "Please check that you have entered proper security code.";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>} else {</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$error = "Please enter all details.";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;html&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;head&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;title&gt;Feedback Form&lt;/title&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;style&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">.error {</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>color:red;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">.accept {</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>color:green;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/style&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/head&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;body&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php if(!empty($error)) echo '&lt;div class="error"&gt;'.$error.'&lt;/div&gt;'; ?&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php if(!empty($accept)) echo '&lt;div class="accept"&gt;'.$accept.'&lt;/div&gt;'; ?&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;table&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td colspan="2" align='center'&gt;&lt;b&gt;Feedback Form&lt;/b&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/tr&gt;</span><br /><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;Enter Your Name:&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;&lt;input type="text" name="name" /&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/tr&gt;</span><br /><span class="Apple-tab-span" style="white-space: pre;"><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;Enter Your Email ID:&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;&lt;input type="text" name="email" /&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/tr&gt;</span><br /><span class="Apple-tab-span" style="white-space: pre;"><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;Feedback:&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;&lt;textarea name="message"&gt;&lt;/textarea&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/tr&gt;</span><br /><span class="Apple-tab-span" style="white-space: pre;"><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;&lt;img src="captcha.php"/&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/tr&gt;</span><br /><span class="Apple-tab-span" style="white-space: pre;"><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;Enter Security Code:&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;&lt;input type="text" name="code" /&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/tr&gt;</span><br /><span class="Apple-tab-span" style="white-space: pre;"><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;&lt;input type="submit" name="submit" value="Submit" class="button" /&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;td&gt;&lt;/td&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/tr&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/table&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/form&gt;</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">&lt;/body&gt;</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;/html&gt;</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b>Now you feedback form with your own captcha is ready to use.</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b><br /></b></span><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;</span><a href="http://www.phpcodeforbeginner.blogspot.in/" style="font-family: Arial, Helvetica, sans-serif;">www.phpcodeforbeginner.blogspot.in</a><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp;for more help.</span></div>https://www.phptutorialforbeginners.com/2013/03/create-your-own-captcha-in-php-or.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-3005701336276363134Thu, 21 Feb 2013 05:21:00 +00002013-03-07T13:46:14.906+05:30PHPhow to redirectredirection in phpredirect in phpphp redirect coderedirect in php with headerredirect script in php301 redirectphp header functionphp redirect302 redirectredirectPHP Redirect(301 Permanent and 302 temporary redirect) or header() Function in php | PHP Tutorial for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will see how to use php redirection function like 301 temporary redirect and 302 permanent redirect.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Some time we want to redirect user to specific page when certain condition are true or false. At this time our php allow you to use his function called header() to redirect the user appropriate location. Simple example to use redirect is in any <a href="http://phpcodeforbeginner.blogspot.com/2012/10/php-simple-login-form-php-tutorial-for.html">login form</a>. If username and password are correct then redirect user to this dashboard else redirect him again to <a href="http://phpcodeforbeginner.blogspot.com/2012/10/php-simple-login-form-php-tutorial-for.html">login form</a>.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><b>PHP Redirect Code</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">header("HTTP/1.1 301 Moved Permanently");&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">header("Location: http://www.phpredirecttutorial.com");&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span></div><span style="font-family: Arial, Helvetica, sans-serif;">It is 301 permanent redirect, because we have used "header("HTTP/1.1 301 Moved Permanently")". If you want to use 302 temporary redirect simply skip this line and write below code.</span><br /><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php&nbsp;</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;">header("Location: http://www.</span><span style="font-family: Arial, Helvetica, sans-serif;">phpredirecttutorial</span><span style="font-family: Arial, Helvetica, sans-serif;">e.com");&nbsp;</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span></div><b><span style="font-family: Arial, Helvetica, sans-serif;">NOTE:-&nbsp;</span><span style="font-family: Arial, Helvetica, sans-serif;">This would result in a "302 Moved Temporarily" redirect instead of a 301 one. This should be avoided as permanent redirects are more search engine friendly and should be used where possible.</span></b><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;</span><a href="http://www.phpcodeforbeginner.blogspot.in/" style="font-family: Arial, Helvetica, sans-serif;">www.phpcodeforbeginner.blogspot.in</a><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp;for more help.</span></div>https://www.phptutorialforbeginners.com/2013/02/php-redirect301-permanent-and-302.html[email protected] (Anil Gupta)2tag:blogger.com,1999:blog-2100928329644461483.post-4353262773103563666Tue, 19 Feb 2013 10:43:00 +00002013-03-07T13:46:26.287+05:30remove spaces in stringPHPphp trim spacestrim functionphp emptytrim white spacephp trim functionstrim function in phpPHP trim() Function | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will show you trim function in php.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><b><u>trim():</u></b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;">Php trim() removes the extra white space from the string.</span><br /><br /><span style="color: blue;"><span style="font-family: Arial, Helvetica, sans-serif;">Example&nbsp;</span><span style="font-family: Arial, Helvetica, sans-serif;">Without trim function:-</span></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo "#"." Php trim function "."#";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><b>Output:-&nbsp;</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b># Php trim function #</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif;">Example With trim function:-</span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo "#".trim("&nbsp;</span><span style="font-family: Arial, Helvetica, sans-serif;">Php trim function</span><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp;")."#";</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><b>Output:-&nbsp;</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>#Php trim function#</b></span><br /><br /><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;</span><a href="http://www.phpcodeforbeginner.blogspot.in/" style="font-family: Arial, Helvetica, sans-serif;">www.phpcodeforbeginner.blogspot.in</a><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp;for more help.</span></div>https://www.phptutorialforbeginners.com/2013/02/php-trim-function-php-tutorials-for.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-4185352514831716266Tue, 19 Feb 2013 07:24:00 +00002013-04-16T15:09:32.964+05:30php session tutorialsession variables in phpPHPsession phpphp sessionsphp session variablephp session functionsphp session examplesession in phpPHP Session Example and PHP Session Tutorial | PHP Tutorials For beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will see how to use php session and give you proper php session tutorial.</span><br /><br /><b style="color: blue; font-family: Arial, Helvetica, sans-serif;"><u><br /></u></b><b style="color: blue; font-family: Arial, Helvetica, sans-serif;"><u>What is php session</u>:-</b><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">In normal HTML web site the&nbsp;boundary&nbsp;of data is limited that is we can not transfer data from one page to another. But in some cases we require to pass our data to another page like <a href="http://phpcodeforbeginner.blogspot.com/2012/10/php-simple-login-form-php-tutorial-for.html">login form</a> or shopping cart websites. In this situation php session help us to transfer the data. The data is user information which is store on server for later use. This information is temporary and it will be deleted when browser is closed.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b>A Session variable is used to store the information of user. We can store any information required for user in session.</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Sessions work by creating a unique identification number for each visitor and storing variables based on this ID. This helps to prevent two users' data from getting confused with one another when visiting the same webpage.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b>Syntax of session is:-</b> $_SESSION['variable_name'].</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><b><u>How to start php session</u>:-</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">We can to use session&nbsp;directly&nbsp;and store the user information. First we need to start the session. To start session we have to write session_start() at the beginning of our code, before any HTML or text.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Before you can begin storing user information in your PHP session, you must first start the session. When you start a session, it must be at the very beginning of your code, before any HTML or text is sent.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Here is the example of how to start the session.</span><br /><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>session_start(); // starting our PHP session!&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><b><u>Storing data in a session variable</u>:-</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">When we want to store user information in session the we have to use $_SESSION. $_SESSION is an associative array. In this all information are stored and&nbsp;retried.&nbsp;</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b>Example:-</b></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">session_start();&nbsp;</span><br /><span style="color: red;"><span class="Apple-tab-span" style="font-family: Arial, Helvetica, sans-serif; white-space: pre;"> </span><span style="font-family: Arial, Helvetica, sans-serif;">$_SESSION['topic'] = "PHP Session example."; // storing session data</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>echo $_SESSION['topic']; //retrieving session data</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><b>Output:-</b></span><br /><span style="font-family: Arial, Helvetica, sans-serif;">PHP Session example.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">In this example we learned how to store a variable to the session associative array $_SESSION and also how to retrieve data from that same array.</span><br /><br /><span style="font-family: Arial, Helvetica, sans-serif;">This example show you how to count the number of time user came in perticular page.</span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>session_start();&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>($_SESSION['number']) ? $_SESSION['number']++ : $_SESSION['number'] = 1;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">This is your &lt;?php echo( $_SESSION['number'] ); ?&gt; time in this page.</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><b><u>Destroying session data</u>:-</b></span><br /><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><b><br /></b></span><span style="font-family: Arial, Helvetica, sans-serif;">Php session data are temporary and will be deleted when we leave page or browser. But in some situation we need to clear user information as soon as task is completed. At this situation we use php function to destroy session.&nbsp;</span><br /><br /><span style="font-family: Arial, Helvetica, sans-serif;"><b>Example:-</b></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>session_start(); &nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if(isset($_SESSION['topic'])){</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>unset($_SESSION['topic']);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span></div><span style="font-family: Arial, Helvetica, sans-serif;">To completely destroy the session you can call the session_destroy function.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b>Example:-</b></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>session_start();&nbsp;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>session_destroy();</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><b>This session_destroy() will completely remove the session.</b></span><br /><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;</span><a href="http://www.phpcodeforbeginner.blogspot.in/" style="font-family: Arial, Helvetica, sans-serif;">www.phpcodeforbeginner.blogspot.in</a><span style="font-family: Arial, Helvetica, sans-serif;">&nbsp;for more help.</span></div>https://www.phptutorialforbeginners.com/2013/02/php-session-php-tutorials-for-beginners.html[email protected] (Anil Gupta)3tag:blogger.com,1999:blog-2100928329644461483.post-8115533812968223299Wed, 06 Feb 2013 11:16:00 +00002013-03-07T13:46:47.911+05:30php tutorialPHPexplode function phpexplode function in phpexplode and implode function in phpphp string functionsimplode function examplephp explode function exampleimplode function in phpPHP Implode and PHP Explode Function | PHP Tutorial for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">In this tutorial of php code for beginners we will see how to use php explode and implode function.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><b><span style="color: blue; font-family: Arial, Helvetica, sans-serif;">PHP explode() Function:-</span></b><br /><span style="font-family: Arial, Helvetica, sans-serif;">Php explode function is used to break a string into an array. We specify the parameter which is used in breaking the string.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b><span style="color: blue;"><u>Syntax of explode function is as follow</u>:-&nbsp;</span></b></span><br /><span style="font-family: Arial, Helvetica, sans-serif; font-size: large;">explode(Separator,String)</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">where 'Separator' specify the position from where to break string and 'String' is actual text which will split.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Here is the example to show php explode function.</span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$string = "PHP tutorial to use explode and implode functions for beginners.";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$data = explode(" ", $string);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">foreach($data as $parts) {</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">echo $parts . "&lt;br/&gt;";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span><br /><b><span style="font-family: Arial, Helvetica, sans-serif;"><u>Output</u>:-</span></b><br /><span style="font-family: Arial, Helvetica, sans-serif;">PHP</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">tutorial</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">to</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">use</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">explode</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">and</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">implode</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">functions</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">for</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">beginners.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div><b><span style="color: blue; font-family: Arial, Helvetica, sans-serif;">PHP implode() Function:-</span></b><br /><span style="font-family: Arial, Helvetica, sans-serif;">Php implode function is used to convert an array into string. It return output as a string.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><b><span style="color: blue;"><u>Syntax of implode function is as follow</u>:-</span></b>&nbsp;</span><br /><span style="font-family: Arial, Helvetica, sans-serif; font-size: large;">implode(Separator,Array)</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">where 'Separator' indicate what to be come in between array elements and 'Array' is one which will get converted into string.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;">Here is the two examples to show php implode function.</span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$string = array("PHP","tutorial","to","use","explode","and","implode","functions","for","beginners.");</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$data = implode(" ", $string);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">echo $data;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span><br /><b><span style="font-family: Arial, Helvetica, sans-serif;"><u>Output</u>:-</span></b><br /><span style="font-family: Arial, Helvetica, sans-serif;">PHP tutorial to use explode and implode functions for beginners.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="color: red; font-family: Arial, Helvetica, sans-serif;">&lt;?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$string = array("PHP","tutorial","to","use","explode","and","implode","functions","for","beginners.");</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">$data = implode("-", $string);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">echo $data;</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?&gt;</span><br /><b><span style="font-family: Arial, Helvetica, sans-serif;"><u>Output</u>:-</span></b><br /><span style="font-family: Arial, Helvetica, sans-serif;">PHP-tutorial-to-use-explode-and-implode-functions-for-beginners.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following&nbsp;<a href="http://www.phpcodeforbeginner.blogspot.in/">www.phpcodeforbeginner.blogspot.in</a>&nbsp;for more help.</span></div>https://www.phptutorialforbeginners.com/2013/02/php-implode-and-php-explode-function.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-3998174965160342761Wed, 30 Jan 2013 12:53:00 +00002013-03-07T13:46:57.568+05:30feedback form phpPHPcontact form in htmlphp contact us form examplecontact forms in phpcontact form in phpcontact php formcontact formphp contact formphp contact form scriptcontact form phpSimple Contact Us Form in Php | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><br /><b><span style="color: blue;">Contact or Feedback Form in PHP:</span></b><br />Contact form is very essential for any web site. You can find every website have contact us form. With <b>Contact us form or feedback form</b> the owner of site comes to know what&nbsp;people&nbsp;think about there site. Php contact form is very easy to create. In this tutorial of php code for beginners I will show you the step by step&nbsp;procedure&nbsp;to create your contact us form in php.<br /><br /><b>First we create a html page for our contact us form. Copy the below code and save as contact.php/ contact.html.</b><br /><br />&lt;html&gt;<br />&lt;body&gt;<br />&lt;table&gt;<br />&lt;form name="contact_form" method="post" action="php_contact_form.php"&gt;<br />&lt;tr&gt;<br />&lt;td&gt;&lt;b&gt;PHP Contact Form&lt;/b&gt;&lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;tr&gt;<br />&lt;td&gt;Subject&lt;/td&gt;<br />&lt;td&gt;&lt;input name="sub" id="sub" type="text" size="75"&gt;&lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;tr&gt;<br />&lt;td&gt;Name:&lt;/td&gt;<br />&lt;td&gt;&lt;input name="name" id="name" type="text"&gt;&lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;tr&gt;<br />&lt;td&gt;Email&lt;/td&gt;<br />&lt;td&gt;&lt;input name="email" id="email" type="text"&gt;&lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;tr&gt;<br />&lt;td&gt;Message&lt;/td&gt;<br />&lt;td&gt;&lt;textarea name="msg" cols="60" rows="5" id="msg"&gt;&lt;/textarea&gt;&lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;tr&gt;<br />&lt;td&gt;&lt;input type="submit" name="Submit" value="Submit"&gt;<br />&lt;/tr&gt;<br />&lt;/form&gt;<br />&lt;/table&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;<br /><br />In above code we have created contact us fields for the end user. As this is Simple contact form in php hence i used only name, subject,email and message fields. You can add more. After clicking submit button "php_contact_us.php" page will be called. This is the php contact page where we fetch the data of contact.html and send it using <a href="http://phpcodeforbeginner.blogspot.com/2012/12/mail-funtion-in-php.html">php mail function</a>.<br /><br /><b>Now we will create "php_contact_us.php" page. In this page we write our php coding to send contact/feedback mail to admin of website.Copy the below code and save as .php_contact_us.php".</b><br /><br />&lt;?php<br />$subject = $_POST['sub'];<br />$name = $_POST['name'];<br />$from = $_POST['email'];<br />$message = $_POST['msg'];<br />$to = "[email protected]";<br />$send_email = mail($to,$subject,$message);<br />if($send_email){<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>echo "Your message is successfully sent!!!";<br />}else{<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>echo "Error in sending contact email!!!";<br />}<br />?&gt;<br /><br />In above code we use $subject to store subject of contact us form. Similarly we have used $name for the Senders name, $from for storing sender email address, $message for you message of feedback, and very important $to where receivers address is set.<br />After storing this data into variable now we have used <a href="http://phpcodeforbeginner.blogspot.com/2012/12/mail-funtion-in-php.html">php mail function</a> to send the mail. After sending mail we are checking is mail sent proper or not. If it is successfully sent then we will show greeting message other wise some error message.</div>https://www.phptutorialforbeginners.com/2013/01/simple-contact-us-form-in-php-php.html[email protected] (Anil Gupta)1tag:blogger.com,1999:blog-2100928329644461483.post-7669667157166467192Wed, 23 Jan 2013 07:26:00 +00002013-03-07T13:47:09.504+05:30horizontal menuPHPphp simple dynamic menudynamic menu in php from databasedynamic menu in phpnavigation barmake dynamic menu phphow to create dynamic menu in phpphp dynamic menu tutorialPHP Dynamic Drop Down Menu, Horizontal Menu in PHP | PHP Tutorial for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><br /><b><span style="color: blue;">What is Menu bar or Horizontal menu?</span></b><br />Menu bar or Horizontal menu is one top most element of any website from where user can navigate to multiple pages. It Helps the user of your site to easily find out element for which he came.<br /><br />Whenever we see or create a website the top most element is <b>Navigation menu</b> or <b>Drop down menu</b> or <b>Horizontal menu</b>. We can&nbsp;Google&nbsp;and get lots of code which create css menu bar which is static. But if we want to create&nbsp;<b>dynamic&nbsp;drop down menu bar</b> then only this code will not help. In Dynamic menu bar or horizontal menu we fetch the menu data from mysql database and show in front end.<br /><br /><b><span style="color: blue;">Difference between Static and Dynamic Menu bar or Horizontal menu.</span></b><br />A static menu bar or horizontal menu is which we can not change from&nbsp;back end&nbsp;or admin panel. The list of menu items inserted in coding will be shown in menu until and unless we change or add them through menu code.<br />Where as the dynamic menu is one which show the menu items fetched from database table. If new item is inserted in database table then it automatically shown in front end menu bar.<br /><br /><span style="color: blue;"><b>PHP dynamic drop down menu or horizontal menu:</b></span><br />In &nbsp;this tutorial of php code for beginners we will show how to create <b>Dynamic drop down menu bar</b> or <b>Dynamic drop down horizontal menu in php</b> with use of mysql database.<br /><br />Create a database named myhotel and two table in it called state and city.<br />The state table contain the state name and state id&nbsp;fields&nbsp; The city table contain city name, city id and state id in which he belong.<br /><br /><b>State table look&nbsp;like:-</b><br />state_id <span class="Apple-tab-span" style="white-space: pre;"> </span>state_name<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>1 <span class="Apple-tab-span" style="white-space: pre;"> </span>Maharashtra<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>2 <span class="Apple-tab-span" style="white-space: pre;"> </span>Gujarat<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>4 <span class="Apple-tab-span" style="white-space: pre;"> </span>Karnataka<br /><span class="Apple-tab-span" style="white-space: pre;"> </span><br /><b>City table look like:-</b><br />&nbsp;city_id<span class="Apple-tab-span" style="white-space: pre;"> </span> state_id<span class="Apple-tab-span" style="white-space: pre;"> </span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; state_name<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>1 <span class="Apple-tab-span" style="white-space: pre;"> </span>1 <span class="Apple-tab-span" style="white-space: pre;"> </span>Mumbai<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>2 <span class="Apple-tab-span" style="white-space: pre;"> </span>1 <span class="Apple-tab-span" style="white-space: pre;"> </span>Pune<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>3 <span class="Apple-tab-span" style="white-space: pre;"> </span>1 <span class="Apple-tab-span" style="white-space: pre;"> </span>Thane<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>4 <span class="Apple-tab-span" style="white-space: pre;"> </span>2 <span class="Apple-tab-span" style="white-space: pre;"> </span>Gandhi nagar<br /><span class="Apple-tab-span" style="white-space: pre;"> </span><br /><span style="color: blue;"><b>Step 1:-</b></span> <b><u>Create a php configuration file which store the mysql database information. In my case it is config.php</u></b><br /><br />&nbsp;&lt;?php<br />$hostname_conn = "localhost";<br />$database_conn = "myhotel";<br />$username_conn = "root";<br />$password_conn = "";<br /><br />$conn = mysql_connect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);<br />mysql_select_db($database_conn, $conn) or die("could not".mysql_error());<br />?&gt;<br /><br /><b><span style="color: blue;">Step 2:-</span> <u>Now create php file which contain your Dynamic menu.</u></b><br /><br />&nbsp;&lt;?php<br />&nbsp;// Included configuration file in our code.<br />include("config.php");<br />?&gt;<br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;title&gt;Dynamic Drop Down menu in php&lt;/title&gt;<br />&lt;link rel="stylesheet" type="text/css" href="style.css"&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;ul id="Drop_Down_Menu"&gt;<br />&lt;?php<br />// Creating query to fetch state information from mysql database table.<br />$state_query = "select * from state";<br />$state_result = mysql_query($state_query);<br />while($r = mysql_fetch_array($state_result)){ ?&gt;<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;li&gt;&lt;a href="#"&gt;&lt;?php echo $r['state_name'];?&gt;&lt;/a&gt;<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;ul&gt;<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;?php<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>$city_query = "select * from city where state_id=".$r['state_id'];<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>$city_result = mysql_query($city_query);<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>while($r1 = mysql_fetch_array($city_result)){ ?&gt;<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;li&gt;&lt;a href="#"&gt;&lt;?php echo $r1['city_name'];?&gt;&lt;/a&gt;&lt;/li&gt;<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;?php } ?&gt;<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/ul&gt;<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;/li&gt;<br />&lt;?php } ?&gt;<br />&lt;/ul&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;<br /><br /><b><span style="color: blue;">Step 3:-</span> <u>Css for you Menu bar. Put this in to style.css file.</u></b><br /><br />&lt;style type="text/css"&gt;<br />ul {<br />&nbsp; &nbsp; font-family: Arial, Verdana;<br />&nbsp; &nbsp; font-size: 14px;<br />&nbsp; &nbsp; margin: 0;<br />&nbsp; &nbsp; padding: 0;<br />&nbsp; &nbsp; list-style: none;<br />}<br />ul li {<br />&nbsp; &nbsp; display: block;<br />&nbsp; &nbsp; position: relative;<br />&nbsp; &nbsp; float: left;<br />}<br />li ul {<br />&nbsp; &nbsp; display: none;<br />}<br />ul li a {<br />&nbsp; &nbsp; display: block;<br />&nbsp; &nbsp; text-decoration: none;<br />&nbsp; &nbsp; color: #ffffff;<br />&nbsp; &nbsp; border-top: 1px solid #ffffff;<br />&nbsp; &nbsp; padding: 5px 15px 5px 15px;<br />&nbsp; &nbsp; background: #1e7c9a;<br />&nbsp; &nbsp; margin-left: 1px;<br />&nbsp; &nbsp; white-space: nowrap;<br />}<br />ul li a:hover {<br />background: #3b3b3b;<br />}<br />li:hover ul {<br />&nbsp; &nbsp; display: block;<br />&nbsp; &nbsp; position: absolute;<br />}<br />li:hover li {<br />&nbsp; &nbsp; float: none;<br />&nbsp; &nbsp; font-size: 11px;<br />}<br />li:hover a { background: #3b3b3b; }<br />li:hover li a:hover {<br />&nbsp; &nbsp; background: #1e7c9a;<br />}<br /><br />&lt;/style&gt;<br /><br /><b>Now your&nbsp;Dynamic&nbsp;drop down menu bar or horizontal menu is ready to use.</b><br /><br />Hope this php tutorial is useful for you. Keep following&nbsp;<a href="http://www.phpcodeforbeginner.blogspot.in/">www.phpcodeforbeginner.blogspot.in</a>&nbsp;for more help.</div>https://www.phptutorialforbeginners.com/2013/01/php-dynamic-drop-down-menu-horizontal.html[email protected] (Anil Gupta)12tag:blogger.com,1999:blog-2100928329644461483.post-173106896045813176Thu, 17 Jan 2013 08:30:00 +00002013-03-07T13:54:50.129+05:30ajax examplesJQUERYjquery ajax examplesjquery and ajaxajax in jqueryjquery with ajaxjquery ajax php examplephp jquery ajaxjquery ajax tutorialjquery ajax functionjquery ajax formjQuery Ajax Tutorial and Example of jQuery Ajax in PHP | PHP Tutorials for Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><span style="color: blue;"><b><u>What is jQuery?</u></b></span><br />jQuery is a lightweight JavaScript library whos aim is "write less, do more". As jQuery is lightweight, it is easier to load in your website and has fast responce. With help of jQuery it much easier to use JavaScript on your website.<br />Jquery eliminates the many lines of code which we are doing in javascript and make them available with help of single method.<br /><br /><span style="color: blue;"><b><u>What is AJAX?</u></b></span><br />AJAX stand for Asynchronous JavaScript and XML. it is used for creating dynamic and fast web pages. Since AJAX is Asynchronous, it helps in updating a part of web page with out reloading the whole page.<br /><br /><b><span style="color: blue;"><u>What About jQuery and AJAX?</u></span></b><br />The combination of jquery and ajax provide powerfull functionality. With jquery ajax you can make request for text or html from your &nbsp;remote server. If data is large you can use json to receive them. After receiving ajax response we can use them in our html page.<br /><br />jQuery provides some powerful set of jQuery AJAX API’s to handle AJAX requests. In normal way of making AJAX calls using JavaScript is a little bit odd as you have to first create an XMLHttpRequest object that depends on the browser and then make an AJAX call. Also sending a form data using AJAX is also bit difficult if we use normal JavaScript approach of calling AJAX.<br />jQuery provides simple yet powerfull functions which have extended the JavaScript AJAX methods and provide more flexible way. Let us see way of doing AJAX things in jQuery.<br /><br />In this tutorial of php code for beginners we will show you how to use Jquery Ajax in your php form.<br />Lets start... To use Jquery Ajax we need to&nbsp;create&nbsp;two files, In first file our html php code present from where we do ajax request. in second file we process the ajax request and return the result to first page.<br /><br /><b><span style="color: blue;">Step 1:-</span></b> <b><u>Create a school.php file and put this code in it</u>.</b><br /><br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;<br />&lt;script&gt;<br />function getdetails(){<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>var name = $('#name').val();<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>var rno = $('#rno').val();<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>$.ajax({<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>type: "POST",<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>url: "details.php",<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>data: {fname:name, id:rno}<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>}).done(function( result ) {<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>$("#msg").html( " Address of Roll no " +rno +" is "+result );<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>});<br />}<br />&lt;/script&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;table&gt;<br />&lt;tr&gt;<br />&lt;td&gt;Your Name:&lt;/td&gt;<br />&lt;td&gt;&lt;input type="text" name="name" id="name" /&gt;&lt;td&gt;<br />&lt;/tr&gt;<br />&lt;tr&gt;<br />&lt;td&gt;Roll Number:&lt;/td&gt;<br />&lt;td&gt;&lt;input type="text" name="rno" id="rno" /&gt;&lt;td&gt;<br />&lt;/tr&gt;<br />&lt;tr&gt;<br />&lt;td&gt;&lt;/td&gt;<br />&lt;td&gt;&lt;input type="button" name="submit" id="submit" value="submit" onClick = "getdetails()" /&gt;&lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;/table&gt;<br />&lt;div id="msg"&gt;&lt;/div&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;<br /><br />In&nbsp;above&nbsp;code we are taking name and roll no of student and pass this to details.php using jquery ajax.<br /><br /><b><span style="color: blue;">Step 2:-</span></b> <b><u>Create details.php and put the below code in it</u>.</b><br /><br />&lt;?php<br />$name = $_POST['fname'];<br />$rno = $_POST['id'];<br /><br />$con = mysql_connect("localhost","root","");<br />$db= mysql_select_db("school", $con);<br />$sql = "SELECT address from students where name='".$name."' AND rno=".$rno;<br />$result = mysql_query($sql,$con);<br />$row=mysql_fetch_array($result);<br />echo $row['address'];<br />?&gt;<br /><br />In above code we are getting address of&nbsp;student&nbsp;with help of his name and roll number.<br /><br /><b>Note: We can do this with help of normal coding but the&nbsp;difference&nbsp;here is we are getting result without refreshing the page and&nbsp;that's&nbsp;the magic of jquery Ajax.</b><br /><br />Don't forget to create database named "school" and table name "students". table student contain the&nbsp;fields&nbsp;name, rno and address.<br /><br />Hope this php tutorial is useful for you. Keep following <a href="http://www.phpcodeforbeginner.blogspot.in/">www.phpcodeforbeginner.blogspot.in</a> for more help.</div>https://www.phptutorialforbeginners.com/2013/01/jquery-ajax-tutorial-and-example-of.html[email protected] (Anil Gupta)22tag:blogger.com,1999:blog-2100928329644461483.post-7264711318381621556Tue, 15 Jan 2013 12:23:00 +00002013-03-15T07:42:52.590+05:30jquery form validation examplesimple jquery form validationbest jquery form validationJQUERYform validation with jqueryform validation in jqueryjquery form validationeasy form validationJquery Simple Form Validation | PHP Tutorial for beginners<div dir="ltr" style="text-align: left;" trbidi="on">In this tutorial of php code for beginners we will look at jquery form validation with example.<br /><div><br /></div><br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;title&gt;JQuery Form Validation&lt;/title&gt;<br />&lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"&gt;&lt;/script&gt;<br />&lt;script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"&gt;&lt;/script&gt;<br />&lt;script type="text/javascript"&gt;<br />&nbsp;$(document).ready(function(){<br />&nbsp; $("#form1").validate({<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;debug: false,<br />&nbsp; &nbsp;rules: {<br />&nbsp; &nbsp; name: "required",<br />&nbsp; &nbsp; dropdown: "required",<br />&nbsp; &nbsp; email: {<br />&nbsp; &nbsp; &nbsp;required: true,<br />&nbsp; &nbsp; &nbsp;email: true<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp;},<br />&nbsp; &nbsp;messages: {<br />&nbsp; &nbsp; name: "Please enter your good name.",<br />&nbsp; &nbsp; email: "Please enter your valid email address.",<br />&nbsp; &nbsp; dropdown: "Please select option from dropdown list.",<br />&nbsp; &nbsp;},<br />&nbsp; &nbsp;submitHandler: function(form) {<br />&nbsp; <br />&nbsp; &nbsp; $.post('nextstep.php', $("#form1").serialize(), function(data) {<br />&nbsp; &nbsp; &nbsp;$('#result').html(data);<br />&nbsp; &nbsp; });<br />&nbsp; &nbsp;}<br />&nbsp; });<br />&nbsp;});<br />&lt;/script&gt;<br />&lt;style&gt;<br />&nbsp;label.error { width: 250px; display: inline; color: red;}<br />&lt;/style&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;form name="form1" id="form1" action="" method="POST"&gt;<br />&nbsp; &nbsp; &lt;label for="name" id="name_label"&gt;Name&lt;/label&gt;<br />&nbsp; &nbsp; &lt;input type="text" name="name" id="name" size="30" value=""/&gt;<br />&nbsp;&lt;br&gt;<br />&nbsp; &nbsp; &lt;label for="email" id="email_label"&gt;Email&lt;/label&gt;<br />&nbsp; &nbsp; &lt;input type="text" name="email" id="email" size="30" value=""/&gt;<br />&lt;br&gt;<span class="Apple-tab-span" style="white-space: pre;"> </span><br />&nbsp;Please Select the City:<br />&lt;select name="dropdown" id="dropdown"&gt;<br />&lt;option value=""&gt;None&lt;/option&gt;<br />&lt;option value="mumbai"&gt;Mumbai&lt;/option&gt;<br />&lt;option value="delhi"&gt;Delhi&lt;/option&gt;<br />&lt;option value="pune"&gt;Pune&lt;/option&gt;<br />&lt;/select&gt;<br />&nbsp;&lt;br&gt;<br />&nbsp;&lt;input type="submit" name="submit" value="Submit"&gt;<br />&lt;/form&gt;<br />&lt;!-- We will output the results from process.php here --&gt;<br />&lt;div id="result"&gt;&lt;div&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;<br /><br /><br />Hope this php tutorial is useful for you. Keep following&nbsp;<a href="http://www.phpcodeforbeginner.blogspot.in/">www.phpcodeforbeginner.blogspot.in</a>&nbsp;for more help.</div>https://www.phptutorialforbeginners.com/2013/01/jquery-simple-form-validation-php.html[email protected] (Anil Gupta)19tag:blogger.com,1999:blog-2100928329644461483.post-3026960053160187534Tue, 15 Jan 2013 11:04:00 +00002013-03-07T13:47:18.172+05:30my sql databasephp database connectionPHPdatabase connection in phpphp database connectivityphp code for database connectionhow to connect database in phpdatabase php tutorialDatabase Connection in Php | PHP Toutorial For beginners<div dir="ltr" style="text-align: left;" trbidi="on"><br />After knowing the basic structure of php, next step is how to connect to the mysql database. To perform basic queries from within MySQL is very easy.This tutorial of phpcodeforbeginners will show you mysql database connection in php.<br /><br />The first thing to do is connect to the database. To connect to mysql databse we use function mysql_connect().<br />Syntax of mysql_connect():-<br />mysql_connect(hostname, username, password)<br /><br />Here "hostname" is name of your host(like 'localhost'), "username" is username of your host(For localhost it is 'roo') and "password" is password of your host site(Default is '').<br /><b>Example:-</b><br />&lt;?php<br />$hostname = "localhost";<br />$username = "root";<br />$password = "";<br /><br />$conn = mysql_connect($hostname, $username, $password) or die("Unable to connect");<br />echo "Connected to MySQL";<br />?&gt;<br /><br />After successfull connection you should see "Connected to MySQL" when you run this script. If you can't connect to the server, make sure your password, username and hostname are correct.<br /><br />Now we have created connection object, next step is to select a database to work with. To select database we use function mysql_select_db() with connection object.<br /><br /><b>Example:-</b><br />&lt;?php<br />//selecting a database with name phptutorials.<br />$database = mysql_select_db("phptutorials",$conn)<br />&nbsp; or die("Could not select phptutorials");<br />?&gt;<br /><br />Now database is selected, let's try and run some queries. The function used to perform queries is named - mysql_query(). The function returns a resource that contains the results of the query, called the result set. To examine the result we're going to use the mysql_fetch_array function, which returns the results row by row.<br /><br /><b>Example:-</b><br />&lt;?php<br />$result = mysql_query("SELECT id, name, address FROM students");<br />while ($row = mysql_fetch_array($result)) {<br />&nbsp; &nbsp;echo "ID:".$row{'id'}." Name:".$row{'name'}." Address:".$row{'year'}."&lt;br&gt;";<br />}<br />?&gt;<br /><br />Finally, we close the connection.<br /><br />&lt;?php<br />mysql_close($conn);<br />?&gt;<br /><br />Here is the full code:<br /><br />&lt;?php<br />$hostname = "localhost";<br />$username = "root";<br />$password = "";<br /><br />//connection to the database<br />$conn = mysql_connect($hostname, $username, $password) or die("Unable to connect");<br />echo "Connected to MySQL";<br /><br />//select database phptutorials<br />$database = mysql_select_db("phptutorials",$conn) or die("Could not select phptutorials");<br /><br />//execute the SQL query and return records<br />$result = mysql_query("SELECT id, name, address FROM students");<br /><br />//fetch tha data from the database<br />while ($row = mysql_fetch_array($result)){<br />&nbsp; &nbsp;echo "ID:".$row{'id'}." Name:".$row{'name'}." Address:".$row{'year'}."&lt;br&gt;";<br />}<br />//close the connection<br />mysql_close($conn);<br />?&gt;</div>https://www.phptutorialforbeginners.com/2013/01/mysql-database-connection-in-php-php.html[email protected] (Anil Gupta)0tag:blogger.com,1999:blog-2100928329644461483.post-3067605021757270379Tue, 15 Jan 2013 08:44:00 +00002013-04-18T17:31:44.774+05:30JQUERYcheck a checkbox using jqueryjava script for validationjquery for validationvalidate form with multiple checkboxcheckbox jquery validationcheckbox validation using jqueryJQuery Validation for Multiple Checkbox Form | PHP Tutorials For Beginners<div dir="ltr" style="text-align: left;" trbidi="on"><br />Sometime we come to the situation where we want to validate the form with multiple checkbox and&nbsp;at least&nbsp;one checkbox is selected.<br />In this tutorial of <a href="http://phpcodeforbeginner.blogspot.in/">phpcodeforbeginner.blogspot.in</a> we validate form with multiple checkboxes with use of jQuery. The result will return true only if atleast one checkbox is selected.<br /><br />In below example we create a html page which have multiple checkboxes. When we click on submit a validate() function will get call and it will check how many checkbox is selected. If nothing is selected then it show javascript alert that "nothing is selected" otherwise it show the javascript alert with no of checkbox selected.<br />It is pretty simple code to validate multiple checkboxes with help of jquery. You can also try validating checkboxes using&nbsp;JavaScript.<br /><br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"&gt;&lt;/script&gt;<br />&lt;script&gt;<br />function validate()<br />{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var fields = $("input[name='checkbox']").serializeArray();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (fields.length == 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert('nothing selected');<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;alert(fields.length + " items selected");<br />&nbsp; &nbsp; &nbsp; &nbsp;}<br />}<br />&lt;/script&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;form action="" method="GET" id="Form"&gt;<br /><br /><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;div&gt;&lt;input name="checkbox" type="checkbox" &nbsp;value="PHP Tutorial" &gt;Php Tutorial&lt;/div&gt;<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;div&gt;&lt;input name="checkbox" type="checkbox" &nbsp;value="Javascript" &gt;Javascript&lt;/div&gt;<br /><span class="Apple-tab-span" style="white-space: pre;"> </span>&lt;div&gt;&lt;input name="checkbox" type="checkbox" &nbsp;value="Validation" &gt;Validation&lt;/div&gt;<br /><br />&lt;input name="submit" type="button" &nbsp;value="submit" onclick="validate();"&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;<br /><br />Hope this jquery form validation for multiple checkboxes tutorial is useful for you. Keep following <a href="http://www.phpcodeforbeginner.blogspot.in/">www.phpcodeforbeginner.blogspot.in</a> for more help.</div>https://www.phptutorialforbeginners.com/2013/01/jquery-validation-for-multiple-checkbox.html[email protected] (Anil Gupta)4