sometimes we are use single page for render html and response ajax request, so we need to detect ajax request or page render request.
In this article i would like to explain how to detect ajax request in Core PHP, Codeigniter and Zend framework and process your code.
Detect Ajax Request In Core PHP
This below code catch ajax request and provide event, so you can process your ajax operations.
//ajax detection code
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' )
// do something
//write your ajax code here
If you want to connect multiple database in single application with codeigniter, just follow below simple steps and setup configuration.
Set multiple database details in database.php file
You should provide all the database details in “application/config/database.php” file with defferent groups, like below examples.
Generally, you have to set default database group, like below code :
//Default database group details
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'myusername';
$db['default']['password'] = 'mypassword';
$db['default']['database'] = 'mydatabase';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
Instant Payment Notification
Instant Payment Notification (IPN) is a message service that automatically notifies merchants by paypal for the transaction related events. Merchants can use this data for the further process of any order or other payment related action in his website.
How IPN works :
Merchants create a IPN data receiver page on their website and then this URL set in his paypal account. Paypal will send all the transaction related data on that given IPN URL. When any user place a order on merchant website and complete payment from paypal then after complete payment paypal send user transaction detail send on merchant IPN listner URL and merchant process user transaction data for user order on his website.
Setting Up IPN on PayPal
The below process describe how to setup IPN in your paypal accounts for sandbox and Live both. Please follow below instructions to set up your IPN listener in your account: Readmore
Windows Push Notification Services (WNS) is a service to send push notifications from server to the any windows application. using the WNS you can send toast, tile, badge, and raw updates from their own cloud service. WNS provide mechanism to send updates to your users in a power-efficient and dependable way.
Creating MySQL Database Table for store user device ids
- create database table for store user information and Device Notify URL.
//Create Table Query
CREATE TABLE IF NOT EXISTS `tbl_users` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`phone_number` varchar(12) NOT NULL,
`notify_url` text NOT NULL,
`created_date` datetime NOT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
- After create table you will store user information and user device notify url. The notify user provided by app developer, this is a user device unique url.
$name = "John Smith";
$email = "firstname.lastname@example.org";
$password = MD5("123456");
$phone_number = "7894561230";
$created_date = date("Y-m-d h:i:s");
//Insert user information with user notify url
$result = mysql_query("INSERT INTO tbl_users(name, email, password, phone_number,notify_url,created_date) VALUES('$name', '$email', '$password', '$phone_number', '$notify_url','$created_date')");
In this article explain how to show preview of selected image without upload. Here I am explain how to preview selected image without uploading image file. You can see preview your selected image using the jquery FileReader elements.
Below show the preview of demo script, if you want to integrate please just follow simple steps and see result.