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)Blogger38125- tag: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 PHP 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;">->Create a Database in phpmyadmin.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">->Create a Table called "main_article" in the Database.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">->In your table create fields called "article_entry_title" and enter some data in it which is used during search.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">->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;">->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;"><?php</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">$database = "Php_Tutorial"; // the name of the database.</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">$server = "localhost"; // server to connect to.</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">$db_user = "root"; // mysql username to access the database with.</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">$db_pass = ""; // mysql password to access the database with.</span><br /><span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;">$table = "users"; // 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;">?></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;"><html></span><br /><span style="color: #cc0000;"><head></span><br /><span style="color: #cc0000;"><span style="white-space: pre;"> </span><title>Creating Search Engine page in php using mysql</title></span><br /><span style="color: #cc0000;"></head></span><br /><span style="color: #cc0000;"><body></span><br /><span style="color: #cc0000;"><form name="php search" action="<?php $_SERVER['PHP_SELF'] ?>" method="POST"></span><br /><span style="color: #cc0000;"><label>Enter Search Keyword:</label><input type="text" name="search_keyword"></span><br /><span style="color: #cc0000;"><input type="submit" value="Search"></span><br /><span style="color: #cc0000;"></form></span><br /><span style="color: #cc0000;"></body></span><br /><span style="color: #cc0000;"></html></span><br /><span style="color: #cc0000;"><br /></span><span style="color: #cc0000;"><?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']) && !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>0)</span><br /><span style="color: #cc0000;">{</span><br /><span style="color: #cc0000;">echo '<b>Total '.$total_rows.' records found for your searched keyword:<br></b>';</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'].'<br>';</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 '<b>Please enter Keyword to search</b>';</span><br /><span style="color: #cc0000;">}</span><br /><span style="color: #cc0000;">?></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 <a href="https://www.phptutorialforbeginners.com/">Php Tutorial for Beginners</a> for more Codes.</span></b></div>https://www.phptutorialforbeginners.com/2013/06/creating-search-engine-in-php-and-mysql.html[email protected] (Anil Gupta)0
- tag: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 <a href="https://www.phptutorialforbeginners.com/">Php Tutorial for Beginners</a> for more help.</span></b></div>https://www.phptutorialforbeginners.com/2013/06/encrypting-password-using-md5-function.html[email protected] (Anil Gupta)0
- tag: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;"><html></span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><head></span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><script src="http://code.jquery.com/jquery-1.9.1.js"></script></span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><style type="text/css"></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;"></style></span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></head></span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><body></span></div><div></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><h1>jQuery show() and hide() example</h1></span></div><div></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><div>This is jquery show() and hide() example</div></span></div><div></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><button id=show_box>show </button></span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><button id=hide_box>hide</button></span></div><div></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><script type="text/javascript"></span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> $("#show_box").click(function () {</span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> $("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;"> $("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;"></script></span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></body></span></div><div><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></html></span></div></div></div><b><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> for more help.</span></b></div>https://www.phptutorialforbeginners.com/2013/06/jquery-show-and-hide-function-php-code.html[email protected] (Anil Gupta)0
- tag: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->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->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->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)0
- tag: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)); </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 <a href="http://www.phpcodeforbeginner.blogspot.in/">Php Tutorials for Beginners</a> for more help.</span></b></div>https://www.phptutorialforbeginners.com/2013/04/reading-extension-of-uploaded-file-in.html[email protected] (Anil Gupta)0
- tag: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;"><html></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><head></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><title>File download in php</title></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></head></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><body></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><table></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><tr><td><a href="download.php?file=download_file_in_php.jpg" class="links">Download file in php</a></td></tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><tr><td><a href="download.php?file=file_download.pdf" class="links">Download pdf</a></td></tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></table></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></body></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></html></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. </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;"><?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;"> 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;"> $size = filesize($file);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> $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;"> $known_mime_types=array(</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>"pdf" => "application/pdf",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>"txt" => "text/plain",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>"html" => "text/html",</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>"htm" => "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" => "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" => "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" => "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" => "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" => "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" => "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" => "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"=> "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" => "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" => "text/plain"</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> );</span><br /><span style="color: red;"><br /></span><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> 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;"> };</span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"> @ob_end_clean(); </span></span><br /><span style="color: red;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"> // required for IE, otherwise Content-Disposition may be ignored</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> if(ini_get('zlib.output_compression'))</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> ini_set('zlib.output_compression', 'Off');</span><br /><span style="color: red;"><br /></span><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> header('Content-Type: ' . $mime_type);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> header('Content-Disposition: attachment; file="'.$name.'"');</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> header("Content-Transfer-Encoding: binary");</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> header('Accept-Ranges: bytes');</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> header("Cache-control: private");</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> header('Pragma: private');</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> readfile($file); </span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?></span></div><div><b><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> for more help.</span></b></div></div>https://www.phptutorialforbeginners.com/2013/04/file-download-script-in-php-php.html[email protected] (Anil Gupta)0
- tag: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 cropping is one of the important part during any website building. To make our uploaded image fix exactly in same diamention in front end 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;"><html></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><head></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><title>Resize image in php</title></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></head></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><body></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <form name = "form" action = "<?php echo $_SERVER['PHP_SELF']; ?>" method = "POST" enctype="multipart/form-data"></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><table></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td><label>Insert Image to resize:-</label></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td><input type = "file" name = "file" id = "file"></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td colspan = 2></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><input type = "submit" value = "submit" name = "submit"></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></table></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </form></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></body></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></html></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. </b></span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><?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 = '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") && ($_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/png") && ($_FILES["file"]["size"] < 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)) </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 </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) </span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">{</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> echo "Image Uploaded Successfully.";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> 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;">} </span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?></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;"><?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 = '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") && ($_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/png") && ($_FILES["file"]["size"] < 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)) </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 </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><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, $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) </span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">{</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> echo "Image Uploaded Successfully.";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> 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;">} </span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><html></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><head></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><title>Resize image in php</title></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></head></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><body></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <form name = "form" action = "<?php echo $_SERVER['PHP_SELF']; ?>" method = "POST" enctype="multipart/form-data"></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><table></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td><label>Insert Image to resize:-</label></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td><input type = "file" name = "file" id = "file"></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td colspan = 2></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><input type = "submit" value = "submit" name = "submit"></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></table></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </form></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></body></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></html></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)4
- tag: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;"><html></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <head></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <script src="http://code.jquery.com/jquery-1.5.js"></script></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <script></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> function countCharacter(input) {</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> 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;"> }</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </script></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </head></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <body></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <textarea id="desc" onkeyup="countCharacter(this)"></textarea></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <div id="charcount"></div></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> </body></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></html></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 </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;"> for more help.</span></div>https://www.phptutorialforbeginners.com/2013/04/character-count-in-jquery-php-tutorials.html[email protected] (Anil Gupta)0
- tag: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->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;"><?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 = $newdb->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;"> echo $cust_record->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;">?></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)0
- tag: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;"><script type="text/javascript" src="jquery.js"></script></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><script></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 < 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"); // 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() { // 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> }</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;"></script></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><?php</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$host="localhost"; </span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$username="root"; </span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$password=""; </span><br /><span style="font-family: Arial, Helvetica, sans-serif;">$db_name="practice"; </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"); </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;">?></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><table width="400" border="0" cellspacing="1" cellpadding="0"></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><tr></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td><form name="form1" method="post" action=""></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><tr></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td>&nbsp;</td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td><strong>Delete multiple rows in mysql</strong> </td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"></tr></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><tr></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td>Check All <input type="checkbox" id="check_all" value=""></td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td><strong>Id</strong></td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td><strong>Name</strong></td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td><strong>Lastname</strong></td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td><strong>Email</strong></td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"></tr></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><?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;">?></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><tr></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td><? echo $rows['id']; ?></td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td><? echo $rows['name']; ?></td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td><? echo $rows['lastname']; ?></td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td><? echo $rows['email']; ?></td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"></tr></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><?php</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;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><tr></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><td><input name="delete" type="submit" id="delete" value="Delete"></td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"></tr></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"><?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 </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<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 </span><br /><span style="font-family: Arial, Helvetica, sans-serif;">if($result){</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">";</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;">?></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"></table></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"></form></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"></td></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"></tr></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"></table></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 <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> for more examples.</span></div>https://www.phptutorialforbeginners.com/2013/03/delete-multiple-records-using.html[email protected] (Anil Gupta)1
- tag: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 different table of WordPress to fetch or store data. But some time during customization we need to create our own table in our WordPress database and store or fetch data from it.</span><br /><span style="font-family: Arial, Helvetica, sans-serif;">For WordPress expert it very simple thing but for beginners it took time to R&d on this. So I thought make it simple and show you the simple step to add your data in your custom table of WordPress.</span><br /><div class="code"><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><?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->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->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->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->query($query);</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?></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;"> for more help.</span></div>https://www.phptutorialforbeginners.com/2013/03/inserting-data-to-custom-table-in.html[email protected] (Anil Gupta)0
- tag: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. </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 variables constants do not have $ sign.</span><br /><div class="code"><br /><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><?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;">?></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 </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;"> for more examples.</span></div>https://www.phptutorialforbeginners.com/2013/03/define-constants-in-php-php-tutorials.html[email protected] (Anil Gupta)2
- tag: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;"><ul></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><?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' => 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); ?></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><?php endforeach; wp_reset_postdata(); ?></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></ul></span></div><span style="font-family: Arial, Helvetica, sans-serif;">Hope this php tutorial is useful for you. Keep following </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;"> for more help.</span></div>https://www.phptutorialforbeginners.com/2013/03/showing-posts-of-perticular-category-in.html[email protected] (Anil Gupta)0
- tag: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 WordPress 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 WordPress and publish it, WordPress 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 WordPress 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 WordPress "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 <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> for more help.</span></div>https://www.phptutorialforbeginners.com/2013/03/remove-default-canonical-tag-from.html[email protected] (Anil Gupta)0
- tag: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;"><?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 < 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;">?></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;"><?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']) && !empty($_POST['email']) && !empty($_POST['message']) && !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;">?></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><html></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><head></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><title>Feedback Form</title></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><style></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;"></style></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></head></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><body></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><?php if(!empty($error)) echo '<div class="error">'.$error.'</div>'; ?></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><?php if(!empty($accept)) echo '<div class="accept">'.$accept.'</div>'; ?></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><table></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"> <tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td colspan="2" align='center'><b>Feedback Form</b></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></span><br /><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td>Enter Your Name:</td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td><input type="text" name="name" /></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></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><tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td>Enter Your Email ID:</td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td><input type="text" name="email" /></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></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><tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td>Feedback:</td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td><textarea name="message"></textarea></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></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><tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td><img src="captcha.php"/></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></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><tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td>Enter Security Code:</td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td><input type="text" name="code" /></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></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><tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td><input type="submit" name="submit" value="Submit" class="button" /></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td></td></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span></table></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></form></span><br /><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><span style="font-family: Arial, Helvetica, sans-serif;"></body></span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;"></html></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 </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;"> for more help.</span></div>https://www.phptutorialforbeginners.com/2013/03/create-your-own-captcha-in-php-or.html[email protected] (Anil Gupta)0
- tag: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;"><?php </span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">header("HTTP/1.1 301 Moved Permanently"); </span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">header("Location: http://www.phpredirecttutorial.com"); </span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?></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;"><?php </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"); </span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?></span></div><b><span style="font-family: Arial, Helvetica, sans-serif;">NOTE:- </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 </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;"> for more help.</span></div>https://www.phptutorialforbeginners.com/2013/02/php-redirect301-permanent-and-302.html[email protected] (Anil Gupta)2
- tag: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 </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;"><?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;">?></span></div><span style="font-family: Arial, Helvetica, sans-serif;"><b>Output:- </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;"><?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(" </span><span style="font-family: Arial, Helvetica, sans-serif;">Php trim function</span><span style="font-family: Arial, Helvetica, sans-serif;"> ")."#";</span></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?></span></div><span style="font-family: Arial, Helvetica, sans-serif;"><b>Output:- </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 </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;"> for more help.</span></div>https://www.phptutorialforbeginners.com/2013/02/php-trim-function-php-tutorials-for.html[email protected] (Anil Gupta)0
- tag: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 boundary 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 directly 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;"><?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! </span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?></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 retried. </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;"><?php</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">session_start(); </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;">?></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;"><?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(); </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;">?></span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">This is your <?php echo( $_SESSION['number'] ); ?> 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. </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;"><?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(); </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;">?></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;"><?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(); </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;">?></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 </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;"> for more help.</span></div>https://www.phptutorialforbeginners.com/2013/02/php-session-php-tutorials-for-beginners.html[email protected] (Anil Gupta)3
- tag: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>:- </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;"><?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 . "<br/>";</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">}</span><br /><span style="color: red; font-family: Arial, Helvetica, sans-serif;">?></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> </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;"><?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;">?></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;"><?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;">?></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 <a href="http://www.phpcodeforbeginner.blogspot.in/">www.phpcodeforbeginner.blogspot.in</a> for more help.</span></div>https://www.phptutorialforbeginners.com/2013/02/php-implode-and-php-explode-function.html[email protected] (Anil Gupta)0
- tag: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 people 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 procedure 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 /><html><br /><body><br /><table><br /><form name="contact_form" method="post" action="php_contact_form.php"><br /><tr><br /><td><b>PHP Contact Form</b></td><br /></tr><br /><tr><br /><td>Subject</td><br /><td><input name="sub" id="sub" type="text" size="75"></td><br /></tr><br /><tr><br /><td>Name:</td><br /><td><input name="name" id="name" type="text"></td><br /></tr><br /><tr><br /><td>Email</td><br /><td><input name="email" id="email" type="text"></td><br /></tr><br /><tr><br /><td>Message</td><br /><td><textarea name="msg" cols="60" rows="5" id="msg"></textarea></td><br /></tr><br /><tr><br /><td><input type="submit" name="Submit" value="Submit"><br /></tr><br /></form><br /></table><br /></body><br /></html><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 /><?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 />?><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)1
- tag: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 Google and get lots of code which create css menu bar which is static. But if we want to create <b>dynamic 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 back end 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 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 fields The city table contain city name, city id and state id in which he belong.<br /><br /><b>State table look 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 /> city_id<span class="Apple-tab-span" style="white-space: pre;"> </span> 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>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 /> <?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 />?><br /><br /><b><span style="color: blue;">Step 2:-</span> <u>Now create php file which contain your Dynamic menu.</u></b><br /><br /> <?php<br /> // Included configuration file in our code.<br />include("config.php");<br />?><br /><html><br /><head><br /><title>Dynamic Drop Down menu in php</title><br /><link rel="stylesheet" type="text/css" href="style.css"><br /></head><br /><body><br /><ul id="Drop_Down_Menu"><br /><?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)){ ?><br /><span class="Apple-tab-span" style="white-space: pre;"> </span><li><a href="#"><?php echo $r['state_name'];?></a><br /><span class="Apple-tab-span" style="white-space: pre;"> </span><ul><br /><span class="Apple-tab-span" style="white-space: pre;"> </span><?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)){ ?><br /><span class="Apple-tab-span" style="white-space: pre;"> </span><li><a href="#"><?php echo $r1['city_name'];?></a></li><br /><span class="Apple-tab-span" style="white-space: pre;"> </span><?php } ?><br /><span class="Apple-tab-span" style="white-space: pre;"> </span></ul><br /><span class="Apple-tab-span" style="white-space: pre;"> </span></li><br /><?php } ?><br /></ul><br /></body><br /></html><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 /><style type="text/css"><br />ul {<br /> font-family: Arial, Verdana;<br /> font-size: 14px;<br /> margin: 0;<br /> padding: 0;<br /> list-style: none;<br />}<br />ul li {<br /> display: block;<br /> position: relative;<br /> float: left;<br />}<br />li ul {<br /> display: none;<br />}<br />ul li a {<br /> display: block;<br /> text-decoration: none;<br /> color: #ffffff;<br /> border-top: 1px solid #ffffff;<br /> padding: 5px 15px 5px 15px;<br /> background: #1e7c9a;<br /> margin-left: 1px;<br /> white-space: nowrap;<br />}<br />ul li a:hover {<br />background: #3b3b3b;<br />}<br />li:hover ul {<br /> display: block;<br /> position: absolute;<br />}<br />li:hover li {<br /> float: none;<br /> font-size: 11px;<br />}<br />li:hover a { background: #3b3b3b; }<br />li:hover li a:hover {<br /> background: #1e7c9a;<br />}<br /><br /></style><br /><br /><b>Now your Dynamic drop down menu bar or horizontal menu is ready to use.</b><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/php-dynamic-drop-down-menu-horizontal.html[email protected] (Anil Gupta)12
- tag: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 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 create 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 /><html><br /><head><br /><script src="http://code.jquery.com/jquery-latest.js"></script><br /><script><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 /></script><br /></head><br /><body><br /><table><br /><tr><br /><td>Your Name:</td><br /><td><input type="text" name="name" id="name" /><td><br /></tr><br /><tr><br /><td>Roll Number:</td><br /><td><input type="text" name="rno" id="rno" /><td><br /></tr><br /><tr><br /><td></td><br /><td><input type="button" name="submit" id="submit" value="submit" onClick = "getdetails()" /></td><br /></tr><br /></table><br /><div id="msg"></div><br /></body><br /></html><br /><br />In above 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 /><?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 />?><br /><br />In above code we are getting address of student with help of his name and roll number.<br /><br /><b>Note: We can do this with help of normal coding but the difference here is we are getting result without refreshing the page and that's the magic of jquery Ajax.</b><br /><br />Don't forget to create database named "school" and table name "students". table student contain the fields 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)22
- tag: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 /><html><br /><head><br /><title>JQuery Form Validation</title><br /><script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script><br /><script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script><br /><script type="text/javascript"><br /> $(document).ready(function(){<br /> $("#form1").validate({<br /> debug: false,<br /> rules: {<br /> name: "required",<br /> dropdown: "required",<br /> email: {<br /> required: true,<br /> email: true<br /> }<br /> },<br /> messages: {<br /> name: "Please enter your good name.",<br /> email: "Please enter your valid email address.",<br /> dropdown: "Please select option from dropdown list.",<br /> },<br /> submitHandler: function(form) {<br /> <br /> $.post('nextstep.php', $("#form1").serialize(), function(data) {<br /> $('#result').html(data);<br /> });<br /> }<br /> });<br /> });<br /></script><br /><style><br /> label.error { width: 250px; display: inline; color: red;}<br /></style><br /></head><br /><body><br /><form name="form1" id="form1" action="" method="POST"><br /> <label for="name" id="name_label">Name</label><br /> <input type="text" name="name" id="name" size="30" value=""/><br /> <br><br /> <label for="email" id="email_label">Email</label><br /> <input type="text" name="email" id="email" size="30" value=""/><br /><br><span class="Apple-tab-span" style="white-space: pre;"> </span><br /> Please Select the City:<br /><select name="dropdown" id="dropdown"><br /><option value="">None</option><br /><option value="mumbai">Mumbai</option><br /><option value="delhi">Delhi</option><br /><option value="pune">Pune</option><br /></select><br /> <br><br /> <input type="submit" name="submit" value="Submit"><br /></form><br /><!-- We will output the results from process.php here --><br /><div id="result"><div><br /></body><br /></html><br /><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-simple-form-validation-php.html[email protected] (Anil Gupta)19
- tag: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 /><?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 />?><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 /><?php<br />//selecting a database with name phptutorials.<br />$database = mysql_select_db("phptutorials",$conn)<br /> or die("Could not select phptutorials");<br />?><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 /><?php<br />$result = mysql_query("SELECT id, name, address FROM students");<br />while ($row = mysql_fetch_array($result)) {<br /> echo "ID:".$row{'id'}." Name:".$row{'name'}." Address:".$row{'year'}."<br>";<br />}<br />?><br /><br />Finally, we close the connection.<br /><br /><?php<br />mysql_close($conn);<br />?><br /><br />Here is the full code:<br /><br /><?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 /> echo "ID:".$row{'id'}." Name:".$row{'name'}." Address:".$row{'year'}."<br>";<br />}<br />//close the connection<br />mysql_close($conn);<br />?></div>https://www.phptutorialforbeginners.com/2013/01/mysql-database-connection-in-php-php.html[email protected] (Anil Gupta)0
- tag: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 at least 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 JavaScript.<br /><br /><html><br /><head><br /><script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script><br /><script><br />function validate()<br />{<br /> var fields = $("input[name='checkbox']").serializeArray();<br /> if (fields.length == 0)<br /> {<br /> alert('nothing selected');<br /> }<br /> else<br /> {<br /> alert(fields.length + " items selected");<br /> }<br />}<br /></script><br /></head><br /><body><br /><form action="" method="GET" id="Form"><br /><br /><span class="Apple-tab-span" style="white-space: pre;"> </span><div><input name="checkbox" type="checkbox" value="PHP Tutorial" >Php Tutorial</div><br /><span class="Apple-tab-span" style="white-space: pre;"> </span><div><input name="checkbox" type="checkbox" value="Javascript" >Javascript</div><br /><span class="Apple-tab-span" style="white-space: pre;"> </span><div><input name="checkbox" type="checkbox" value="Validation" >Validation</div><br /><br /><input name="submit" type="button" value="submit" onclick="validate();"><br /></body><br /></html><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