<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHP Archives - Postnidea</title>
	<atom:link href="https://www.postnidea.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.postnidea.com/category/php/</link>
	<description>Programming Blog, Tutorials, jQuery, Ajax, PHP, MySQL and Demos</description>
	<lastBuildDate>Tue, 27 May 2025 09:13:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.8</generator>

<image>
	<url>https://www.postnidea.com/wp-content/uploads/2019/08/favicon.ico</url>
	<title>PHP Archives - Postnidea</title>
	<link>https://www.postnidea.com/category/php/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>php data scraping techniques</title>
		<link>https://www.postnidea.com/php-data-scraping-techniques/</link>
		
		<dc:creator><![CDATA[Rakesh Kumar]]></dc:creator>
		<pubDate>Sun, 15 Apr 2018 18:47:00 +0000</pubDate>
				<category><![CDATA[Data mining]]></category>
		<category><![CDATA[Data scraping]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php class]]></category>
		<category><![CDATA[php data scraping]]></category>
		<category><![CDATA[Data Mining]]></category>
		<category><![CDATA[Data Scraping]]></category>
		<guid isPermaLink="false"></guid>

					<description><![CDATA[<p>Data is very important for an organization. With the help of data, an organization can generate a lot of business. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/php-data-scraping-techniques/">php data scraping techniques</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div dir="ltr" style="text-align: left;">
<p>Data is very important for an organization. With the help of data, an organization can generate a lot of business. It works same as like fuel for an engine. Quality of data will increase your business. But the question comes out how to collect data. There are various ways you can collect the data for our organization or business. There is a lot of platforms that provide you paid data.  They charge a small amount of money &amp; will provide you a data. Another way to scarp data from document, website or text file.</p>
<p>Data scraping is that way from which you can extract the required data. The data available on the web pages, XML feed, post feeds but there is a no way to save data in a required format so that it can easy to navigate  &amp; usage. With the help of data scraping, you can extract &amp; save data in the data source and can be used for our business strategy.</p>
<h2 style="text-align: left;">Why people do scrap</h2>
<div style="text-align: left;"></div>
<ul>
<li>collect the current price of the products so that competitors can analyze the market.</li>
<li>Get always updated data when no API  communication source is available.</li>
<li>Generate the business lead from the contact details.</li>
<li>survey usage so  that you can collect the poll data</li>
</ul>
<p>&nbsp;</p>
<h2 style="text-align: left;">How can be achieved?</h2>
<p>There is different language platform provides a different way. I belong to PHP so, I will show a method that used PHP.  With the Use of PHP, you can use three-way from which you extract the data.</p>
<div style="text-align: left;"></div>
<ul>
<li>Document Parsing</li>
<li>Jquery Like PHP Library(simple_html_dom)</li>
<li>Regular Expressions</li>
</ul>
<p>&nbsp;</p>
<div style="text-align: left;"></div>
<p>Before explaining above three techniques I want to take some HTML structure. So that I can use in explaining techniques.</p>
<p><script src="https://pastebin.com/embed_js/Gc2THL6M"></script></p>
<p>Above code will display a list of users. Now I try to extract above users &amp; show in the array.</p>
<p>Now before starting this, we need to get the html structure using URL. In PHP there is two functions are available which get the HTML of the page using URL file_get_contents, another using curl. Curl is very effective because it works faster, extract HTML structure even SSL available. So, Now I create a function return an HTML structure of the page using URL using curl.</p>
<p><script src="https://pastebin.com/embed_js/ZTuDMU6Z"></script></p>
<p>Now with the use of above function, you can get the HTML structure of the page. Now I  explain you data extraction technique one by one.</p>
<h2 style="text-align: left;">PHP Document Parsing</h2>
<p>It simply loads the HTML document &amp; parses into a tree. You can simply say it convert HTML document to XML. With applying query you can extract the data. But its&#8217;s time-consuming process because first it loads &amp; parses structure then your query will work. For long HTML structure document, it consumes a lot of memory. Now I show example code that will show you how it works.</p>
<h2 style="text-align: left;">Jquery Like PHP Library(simple_html_dom) for data scrap</h2>
<p>It&#8217;s also a same above like document parsing. But With the help of class like simple_html_dom, Scraper, hQuery make easy to use. If you are comfortable with jquery then the class will make your life easy. They work like just a jquery functions. Now I show you an example that uses the simple_html_dom library. You can download library using below link &amp; include in our code.</p>
<p>https://sourceforge.net/projects/simplehtmldom/</p>
<h2 style="text-align: left;">Regular Expressions</h2>
<p>It&#8217;s very fast processing data scrap techniue. It&#8217;s not parsing the HTML structure into XML or tree. It treat HTML structure as string &amp; perform serach operation. But for creating regular expression according business logic it&#8217;s very time consuming. Currenty I have taken simple structure.</p>
<p><script src="https://pastebin.com/embed_js/Pcm1uaY5"></script></p>
<p>Now finally I will recommend regular expression technique if you plan for large data extraction. Last but not least never use the browser for data extraction always try to use terminal or command prompt for data scrapping so that your script will run for the longtime &amp; data will be extracted without distortion.</p>
</div>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/php-data-scraping-techniques/">php data scraping techniques</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>wordpress posts validation using ajax in backend</title>
		<link>https://www.postnidea.com/wordpress-posts-validation-using-ajax-in-backend/</link>
					<comments>https://www.postnidea.com/wordpress-posts-validation-using-ajax-in-backend/#respond</comments>
		
		<dc:creator><![CDATA[Rakesh Kumar]]></dc:creator>
		<pubDate>Tue, 01 Aug 2017 02:57:00 +0000</pubDate>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress contextual help]]></category>
		<category><![CDATA[wordpress plugin]]></category>
		<category><![CDATA[ajax validation]]></category>
		<category><![CDATA[post ajax validation]]></category>
		<category><![CDATA[wordpess post validation]]></category>
		<guid isPermaLink="false"></guid>

					<description><![CDATA[<p>In WordPress already so many hooks &#38; filter available with the help of that you can customize the wordpress according [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/wordpress-posts-validation-using-ajax-in-backend/">wordpress posts validation using ajax in backend</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div dir="ltr" style="text-align: left;">
<p>In WordPress already so many hooks &amp; filter available with the help of that you can customize the wordpress according to our needs. But there are some customizations that are required more tricky solutions. For handling ajax request WordPress already define our rules &amp; standards but sometimes there is a need to performing ajax request on the default page saving. For the javascript WordPress uses js enqueue<br />
function with the help of you can attach javascript files &amp; functions. For creating ajax request action WordPress uses two below functions</p>
<p>When you calling the actions publically the use the below functions. There is no need requirement of the login.<br />
admin_post_nopriv_{action_name}<br />
If you want action to execute only when the user login.<br />
admin_post_{action_name}</p>
<p>If you want to call an action on login or without login then use both functions. Now I show you how to call the action in our Ajax request.<br />
http://your_host/admin-ajax.php<br />
On above URL you can pass the action: name using a post or get request then execution of the action occurs. But some problem comes due to customization then there is a need a tricky solution. You can see the below problem.</p>
<p>Problem:</p>
<p>We need to add some extra fields (custom fields) on WordPress backend page. When a user clicks on &#8220;publish&#8221; button then we call the API &amp; values fill with the response from the API then we submit WordPress page form. We implemented all but page always goes to Draft.</p>
<p>Solution:<br />
In a below code post status select box I have check if there is user select &#8220;Draft&#8221; I set the draft otherwise we put the status the publish so that we have to fix that problem. The above-explained things done by function &#8220;check_status&#8221;.</p>
<pre><code>
$("#publish:button").click(function(){
	$.get("url").done(function(data){
		if(check_status()){} else{
		$("#acf-field-region").after("");
		}

		$(document).find("#publish").prop("type", "submit");
		setTimeout(function(){

		$("#post").submit();

		},100);

		return false;
	})
	event.preventDefault();
});
</code></pre>
<pre><code>
function check_status(){
	var status=0;
	jQuery("#post_status option").each(function(){
		if(jQuery(this).val()=="publish"){
			status=1;
		}
	});
	return status;
}
</code></pre>
</div>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/wordpress-posts-validation-using-ajax-in-backend/">wordpress posts validation using ajax in backend</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.postnidea.com/wordpress-posts-validation-using-ajax-in-backend/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>top ecommerce open source list : how to choose best one</title>
		<link>https://www.postnidea.com/top-ecommerce-open-source-list-how-to-choose-best-one/</link>
					<comments>https://www.postnidea.com/top-ecommerce-open-source-list-how-to-choose-best-one/#comments</comments>
		
		<dc:creator><![CDATA[Rakesh Kumar]]></dc:creator>
		<pubDate>Sat, 11 Feb 2017 16:22:00 +0000</pubDate>
				<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[woocommerce]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[Ecommerce]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">https://www.postnidea.com/top-ecommerce-open-source-list-how-to-choose-best-one/</guid>

					<description><![CDATA[<p>Nowadays e-commerce stores more popular because every seller wants a store. In e-commerce business scale not matter there is small [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/top-ecommerce-open-source-list-how-to-choose-best-one/">top ecommerce open source list : how to choose best one</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div dir="ltr" style="text-align: left;">
<p style="text-align: justify;">Nowadays e-commerce stores more popular because every seller wants a store. In e-commerce business scale not matter there is small scale business or large scale business. I have seen in every ten customers 2 or 3 customer demand for the online store development. When such type requirement reaches the technical manager then he always thinks how to move towards the development weather develop store using core development or choose an any CMS like Magento, opencart, woocommerce, Magento, oscommerce, cscart, prestashop. If he moves using core development then there is required more time everything made from scratch and most of the time gone in testing. In other hand client started marketing so he wants our product as soon as possible in that case technical manager have pressure so, the only option left to choose any CMS so that I can be completed on time. You can&#8217;t choose any cms without any complete requirement so, before choosing any cms put out the below question towards the client.</p>
<ul>
<li>How many products you want to sell</li>
<li>you have an existing store and want to migrate it or want a fresh store.</li>
<li>If customer have existing store then evaluate their traffic</li>
<li>Try to collect inform regarding store built on which technology like any opensource or core. If it&#8217;s on open source then try to evaluate customization</li>
<li>existing store currently integrated with any android APP or any API</li>
<li>last but not least you want to launch your store on which type hosting is it shared hosting, dedicated hosting or dedicated server.</li>
</ul>
<p>After finding the answer you can review below information which can help you. I describe below important information regarding each CMS.</p>
<h2>Woocommerce</h2>
<p>The base of woo commerce is WordPress so it&#8217;s good for the less number of products. Also, it&#8217;s not more secure if want secure then there is need to add more security measure. It&#8217;s chocked out when a number of user &amp; their visits increases. But there is enhancement is easy because a lot of plugins available that can enhance the functionality. The default woocommerce  full fill most of the requirement but if still required then you can it. Wocoomerece follows class based structure &amp; easily override the template in your theme. Its working fine in all hosting because it handles small e-commerce business.</p>
<h2><b>Opencart</b></h2>
<p style="text-align: justify;">Opencart follows the MVC (model view controller) and another component also maintains language so that you can manage multiple languages just putting the separate files for each language. Its MVC based so there it&#8217;s easy to understand for every programmer. Its maintain the standard like view only contain represent part same model communication with the database so each query will be found in the model.</p>
<p style="text-align: justify;">controller work as routing &amp; execution. For enhancement, there is need programmer. But it&#8217;s more secure &amp; has a capacity to holds a number of products &amp; customers. It&#8217;s working fine with dedicated hosting or dedicated server. On shared hosting, it&#8217;s unable to handle more traffic So it&#8217;s required more resource but with that, it&#8217;s more secure &amp; handles more powerful.</p>
<h2><b>Oscommerce</b></h2>
<p style="text-align: justify;">It&#8217;s oldest e-commerce CMS so its follows core class &amp; function-based structure. It&#8217;s also good but its unable to handle a large number of products. When your products count goes greater than 1000 then its load slowly &amp; take a lot of time rendering data, so visitor can&#8217;t wait to move another one, in that case, you lose it business. Now there latest build they launched the cache version that can enhance but the previous version has the problem. So it&#8217;s also better for the medium scale business. There is one more thing it provides less amount of payment support for new payment &amp; delivery option need to integration.</p>
<h2><b>Prestashop</b></h2>
<p style="text-align: justify;">It&#8217;s used most like CakePHP structure. Its maintain the separate view section, class for database &amp; controller same as above controlling route. One most powerful feature is that it&#8217;s used cookies &amp; cache for maintaining the data on the visitor side. The Prestashop community also provides the module generator so that its easy for a developer for a cretae new module. It also provides most of the payment, delivery social integration inbuilt So there is no more requirement of development. It has a great capacity to handle near about 3000 products &amp; 50,000 customers without consuming a lot of resources. So it&#8217;s better.</p>
<h2><b>Magento</b></h2>
<p style="text-align: justify;">If I talk about the performance it has the same as PrestaShop but it&#8217;s required more resource. But if you used a dedicated server or hosting then it definitely works for you. It follows the Zend framework so there performance better previous one but the problem only is that it consume more resource. But its most powerful for large amount business it handles more number of user &amp; products.</p>
</div>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/top-ecommerce-open-source-list-how-to-choose-best-one/">top ecommerce open source list : how to choose best one</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.postnidea.com/top-ecommerce-open-source-list-how-to-choose-best-one/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>jquery form validation using php with mysql database</title>
		<link>https://www.postnidea.com/jquery-form-validation-using-php-with-mysql-database/</link>
					<comments>https://www.postnidea.com/jquery-form-validation-using-php-with-mysql-database/#respond</comments>
		
		<dc:creator><![CDATA[Rakesh Kumar]]></dc:creator>
		<pubDate>Mon, 16 Jan 2017 17:45:00 +0000</pubDate>
				<category><![CDATA[dynamic form validation]]></category>
		<category><![CDATA[form validation]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[validation library]]></category>
		<category><![CDATA[Form validation]]></category>
		<category><![CDATA[Jquery form validation]]></category>
		<category><![CDATA[mysql database validation]]></category>
		<category><![CDATA[php server side validation]]></category>
		<guid isPermaLink="false"></guid>

					<description><![CDATA[<p>Nowadays jquery or Javascript is more prominent. Every client wants their application to become faster &#38; user interactive so they [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/jquery-form-validation-using-php-with-mysql-database/">jquery form validation using php with mysql database</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div dir="ltr" style="text-align: left;">
<p style="text-align: justify;">Nowadays jquery or Javascript is more prominent. Every client wants their application to become faster &amp; user interactive so they good user experience, get more customer. Whenever you complete our functionality with ajax request that makes attractiveness because user stays on the same page he sees there task also complete only dom element manipulation occurring. So I figure one common functionality required everywhere which form validation. Without form validation, you can not be complete our functionality of our requirement.</p>
<p style="text-align: justify;">A few days ago I was written a PHP class that deal with validation you can review by click on that link <a title="PHP class for form validation" href="http://postnidea.com/php-class-form-validation/">Click</a>. So in this validation, i write methods of different validation like blank, number, email, validation of field from database like a username. When you review code <a title="PHP class for form validation" href="http://postnidea.com/php-class-form-validation/">Click</a> you will find there is no ajax no form code only a PHP class which shows validation. So require a javascript class that can use for process our request.</p>
<h2>Implementation of jquery form validation using php with mysql database</h2>
<p style="text-align: justify;">Now we start to create a javascript class for processing form. For my javascript code, i have dependency with bootstrap which common CSS framework, with the usage of that framework you can complete our application with responsive design without any help of a designer.<br />
I write a small chunk of code a form which is below.</p>
<p><script src="https://gist.github.com/postnidea/5d8d29110513ca37bb2a604ec03ee4fa.js"></script></p>
<p style="text-align: justify;">In above code, form tag has two selectors like id, action both are required for the form processing. Action are required on which you form being processed. ID is required for pick values suppose if multiple forms then it will more helpful. Another is &#8220;Submit&#8221; button with their click event we fire a request &amp; process it. After processing it will return JSON format response on the basis of that we can manipulate the DOM elements. So we require a function when we click on the submit button it will perform required function. Now below I write a code.</p>
<p><script src="https://gist.github.com/postnidea/2ace7272561b0d54ddad8f4f732d4d3c.js"></script></p>
<p style="text-align: justify;">In above code &#8220;server_validation&#8221; its function for which need to pass the certain parameter on the basis of that it perform form processing. The parameter explanation is below</p>
<p>form_id:&#8217;add_form&#8217; // its the Id of form<br />
button_id:&#8217;add_button&#8217;, // its the Id button<br />
after_success:load_success // its the name of function that call after success of form.</p>
<p>With the help of above code you can just validate form but if you want any callback function then call below function</p>
<p><script src="https://gist.github.com/postnidea/56a36d3d831215a889015dc28a332055.js"></script></p>
<p style="text-align: justify;">In the above code, every thing is same only I added the &#8220;after_success&#8221; variable in which I pass the name of the function that needs to call after the success of form.</p>
<p><a class="btn btn-primary btn-blue" href="http://demo.postnidea.com/jquery-form-validation-using-php/" target="_blank" rel="noopener noreferrer">Demo</a> <a class="btn btn-primary btn-blue" href="https://github.com/postnidea/jquery-form-validation-using-php" target="_blank" rel="noopener noreferrer">code</a></p>
</div>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/jquery-form-validation-using-php-with-mysql-database/">jquery form validation using php with mysql database</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.postnidea.com/jquery-form-validation-using-php-with-mysql-database/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PHP class for form validation</title>
		<link>https://www.postnidea.com/php-class-for-form-validation/</link>
					<comments>https://www.postnidea.com/php-class-for-form-validation/#comments</comments>
		
		<dc:creator><![CDATA[Rakesh Kumar]]></dc:creator>
		<pubDate>Sun, 31 Jul 2016 13:50:00 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[php class]]></category>
		<category><![CDATA[validation]]></category>
		<category><![CDATA[Form validation]]></category>
		<category><![CDATA[php server side validation]]></category>
		<category><![CDATA[PHP validation class]]></category>
		<guid isPermaLink="false"></guid>

					<description><![CDATA[<p>PHP plays great role in the form values sensitization. PHP provide filters with the help of that you plays with [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/php-class-for-form-validation/">PHP class for form validation</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div dir="ltr" style="text-align: left;">
<p>PHP plays great role in the form values sensitization. PHP provide filters with the help of that you plays with form validation &amp; sensitization of form values. PHP provides three types of filter which is below.</p>
<ul>
<li> Validate filters</li>
<li> Sanitize filters</li>
<li> Other filters</li>
</ul>
<p><b>Validate filters</b><br />
PHP provide in built function for some values validate like email, url, IP address, int , float &amp; regx validation.<br />
for more information</p>
<p><b>Sanitize filters</b><br />
Sanitize filters are used for making valid input so that in future it will create the hole in application. With maintian validation user can be input such a values that can break the functionlity like not inserted in the database or can input the code that can be used in the future. So Sanitize filters can be filter the user inputs.</p>
<p><b>Other filters </b><br />
PHP faciliate to developer he can be add our custom function. That function can be call at time of validation.</p>
<p>So with the usage of these function ii try to create  a class that can be used for validation form. The class that i have written in which covered the below validation.</p>
<ul>
<li>Email validation</li>
<li>Required validation</li>
<li>Numeric validation</li>
<li>positive numeric validation</li>
<li>positive integer validation</li>
<li>URL</li>
<li>Alpha</li>
<li>Alphanumeric</li>
<li>Unique value in database</li>
<li>two parameter field value comparison</li>
<li>Max &amp; Min character limit</li>
<li>Photos</li>
<li>upload validation</li>
</ul>
<h2>PHP Form validation Library</h2>
<p>So below i will show you structure of the class how to be processed. We cretae the seprate function each above validation. which is shown to you in below code.</p>
<p>You can get here code of <a class="btn btn-primary btn-blue" href="https://gist.github.com/rakeshkumar125/2673a98bccfd3a1e13c03b335d7d8f6a">PHP Form Validation Library</a></p>
<h2>Use of PHP Form validation Library</h2>
<p>Now show to how to be use this class. So, First need to initialize the Class with config array, from the config array it will get the data &amp; process it. For different validation how to call. In below code first need to initialize the array. Then provide the one dimensional array to validate for array variable [array_to_validate]. Here just need to pass the name of the element the class will process there values &amp; return the validation status. For example [$config[&#8217;email&#8217;]] assign account_email, alternative_email textbox name so that it can be validate.</p>
<p>Now let me show you with code.</p>
<pre><code>$config = array();
$config['array_to_validate'] = $_POST or array_need_to_validate;
$config['email'] 	     = "email,forgot_email";
$config['required']	     = "date_birth,phone,mobile";
$config['numeric']	     = "mobile";
$config['positive_numeric']  = "positive_number";
$config['positive_integer']  = "positive_integer";
$config['url']		     = "url";
$config['alpha']	     = "name";
$config['alphanumeric']	     = "user_password";
</code></pre>
<p>Now its some thing different because this validation the database. field_name means provide the textbox name or element that need to validation.</p>
<p>Implimentation of unique value in database like user name:</p>
<pre>$config['unique_from_table']= array(
				array(
				'field_name' =&gt;'',
				'table_name' =&gt;'user',
				'table_field'=&gt;'username'
				),
				array(
				'field_name' =&gt;'',
				'table_name' =&gt;'users',
				'table_field'=&gt;'username'
				)
			);
</pre>
<h2>Comparasion</h2>
<pre><code>
$config['compare']= array(
			array(
				'field_name' =&gt;'username',
				'compare_field_name' =&gt;'firstname',
			),
			array(
			  'field_name' =&gt;'lastname',
			  'compare_field_name' =&gt;'firstname'
			)
		);
</code></pre>
<h2>Character Limit Validation</h2>
<pre><code>
$config['min_character_limit']= array(
				    array(
					'field_name' =&gt;'username',
					'no_of_character' =&gt;'20',
				    ),
				    array(
					'field_name' =&gt;'lastname',
					'no_of_character' =&gt;'30'
				    )
				);

$config['max_character_limit'] = array(
								array(
									'field_name' =&gt;'username',
									'no_of_character' =&gt;'20',
								),
								array(
									'field_name' =&gt;'lastname',
									'no_of_character' =&gt;'30'
								)
							);

</code></pre>
<p>Finally call the class &amp; pass all things which we have built in above. Then class will process your inputs &amp; return the result. If there is validation error then return array of error otherwise pass it.</p>
<pre><code>
$my_validator = new validator($config)
$error = $my_validator-&gt;process_validation();
</code></pre>
</div>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/php-class-for-form-validation/">PHP class for form validation</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.postnidea.com/php-class-for-form-validation/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
