Posts

Showing posts from 2015

Google reCAPTCHA with PHP tutorial

Image
Login to your Google account and submit the form. Once submit, Google will provide you following two information. Site key Secret key Integrate it into your website. To integrate it into your website you need to put it in client side as well as in Server side. In client HTML page you need to integrate this line before <HEAD> tag. <script src='https://www.google.com/recaptcha/api.js'></script> And to show the widget into your form you need to put this below contact form, comment form etc. < div class = "g-recaptcha" data-sitekey = "== Your site Key ==" >< / div > When the form get submit to Server, this script will send ‘g-recaptcha-response’ as a POST data. You need to verify it in order to see whether user has checked the Captcha or not. Simple comment form with Google reCAPTCH: Index.html < html >   < head >     < title > Google recapcha demo - Co

How to create and call stored procedure in MySQL with IN and OUT parameters

Create and Call MySQL stored procedure with IN Parameters Here is the command to create a MySQL stored procedure with one IN parameter , here we are getting total number of employee by department, dept_id is a foreign key from department table. mysql > DELIMITER // mysql > create procedure usp_totalEmployeeByDeparment ( IN id INT )     -> begin     -> select count (*) as total from employee where dept_id = id ;     -> end // Query OK , 0 rows affected ( 0.00 sec ) mysql > DELIMITER ; We have first changed delimiter as // to mark end of stored procedure, and then reverted it back to previous delimiter. Also using “usp” as prefix for user defined stored procedure is one of the SQL best practices to separate system and user stored procedures. Now you can call this stored procedure from MySQL command prompt as : mysql > call usp_totalEmployeeByDeparment ( 2 ); + -------+ | total | + -------+ |

[PHP]Conventional v/s Configurable

ravimanephpmysql Types of MVC: Conventional v/s Configurable Now a days all the applications are being created using the MVC architecture, as it a most powerful and successful way to develop the application. In this article we will see comparison of different types of MVC architecture we have, which are as below:     Convention Based MVC     Configuration Based MVC Types of MVC Architecture Convention Based MVC As the name suggest, in this type of MVC we need to follow some predefined conventions in order to have it in working mode. This conventions are different from frameworks to frameworks. There are numbers of frameworks out there which follows convention based approach. Some of those frameworks are as below:     CakePHP     Codeigniter     YUI     Kohana In this article we will see convention approach of the Codeigniter, we will see what types of convention are be there for creating a new model in Codeigniter. First convention is storing of file,

What happens to cronjobs scheduled when the server is off?

ravimanephpmysql Question :I have an Ubuntu Server 12 which isn't on all day. In the /etc/crontab, I see that cron.daily, cron.weekly and cron.monthly are scheduled at times the server is off, usually.What happens with those tasks? Will they just be skipped, or runned as soon as the server is on again. ANSWER: cron skips jobs if it isn't running at the time that they are scheduled. However, if you have anacron installed, then daily, weekly and monthly jobs are run "at the specified intervals as closely as machine uptime permits". In /etc/crontab, you should see references to anacron. This logic uses anacron for regular jobs, but only if anacron is installed. anacron is installed by default on Ubuntu Desktop, but not on Server, since servers are generally expected to be on 24/7. But you can install anacron on Ubuntu Server if you want the same behaviour there, and it should work as expected.

What is Cron Job In Php and it's basic types. and what is server is off at cron job time

ravimanephpmysql This depends on which cron scheduler you use. The basic, vanilla cron daemon will not run tasks that were missed due to system downtime. However, there are other cron schedulers specifically designed for this situation which will do this for you. The two most common examples are anacron and fcron .

[PHP] Create MySQL Trigger in PHP

phpmysql Introduction When we want to execute a specific task at a scheduled time, MySQL provides special functionality called triggers. Triggers are basically named blocks of code that are executed, or fired, automatically when a specified type of SQL statement is executed. Triggers can be executed before after an INSERT, UPDATE or DELETE statement is executed on the table. Syntax CREATE TRIGGER trigger_Name {Before|After}{Insert|Update|Delete}ON table_name For  EACH  ROW sql_block For Example Using the following query, you can better understand what a trigger is and how to use a trigger to execute a specific task at a scheduled time. Query The following query creates a  trigger named "MysqlTrigger", this trigger is associated with the name emp table and is fired before an update. When you try to update a name with lower case, it will automatically convert it to UPPER case . "CREATE TRIGGER MysqlTrigger BEFORE UPDATE ON "emp&