Manage Your Smartphone Easily with MoboRobo Now

Connection Wizard PHP and ASP

Connection Wizard

Having a Smartphone is not a big deal nowadays. It has become so mainly due to availability of Smartphones that are suitable for different budgets. Although there are a number of exceptions, major issue of low-budget Smartphones is their lower screen size. Albeit the fact that you might not face issues while performing common tasks like listening to music and messaging on WhatsApp, the notable issues will be when you want to manage information in your device such as editing contacts, downloading applications massively, managing media files including videos and music etc.

It is likely that these managing sections will be a problem even in a Smartphone with big screen size. MoboRobo is one of effective solutions to solve this issue of small screen size, and is available for Smartphones running on Android and iOS. Of course, MoboRobo has proved its effectiveness since its launch and we’ll go deep into this application so that you can understand why and how should you use MoboRobo to simplify process of Smartphone management. First, we will have a brief and basic introduction to MoboRobo as one of the best Smartphone management software. As we go further into MoboRobo, we can understand its multipurpose behaviour.
Basics You Should Know about MoboRobo
Well, if you are just considering MoboRobo as an application, we can label it a Smartphone management tool, which does offer support for devices running on Android and iOS (iPhones). If you have the latter device but do not have a Mac to get the full-fledged management experience, MoboRobo will be damn useful for you. In addition, even if the Android Smartphone you have does not have a dedicated management tool, you can understand its value. And, the best part of MoboRobo is that it is completely free to use. Furthermore, MoboRobo is useful for both Smartphone users and vendors. There are a number of tasks that you can complete using MoboRobo, ranging from basic level to expert. Now, we’ll have a look on notable tasks you can accomplish using this Smartphone management tool.What to do using MoboRobo
As we have mentioned earlier, you can use MoboRobo for a number of purposes. Some of those notable tasks are as follows.
Make Your Data Secure
If you are one who runs experiments in your Smartphones, more probably in an Android device, data backup feature of MoboRobo is a wonderful solution, as it lets users backup and restore information in an easy way. Backing up your data is an easy task in MoboRobo, and you can do it right from home screen of MoboRobo. Using this feature, you’ll be able to back up variety of information; it includes contacts, call logs, music files, themes, wallpapers, messages as well as images. You can store these backup files in a secure place in PC and use it to restore if you come to lose data from device in any manner. In addition to this, ability to import and export contacts in a convenient format will help users transfer contacts from one platform to another — Android to iPhone or vice versa.
Manage your Applications
More often than not, downloading applications from Google Play Store and installing them in your Smartphone is an extremely tough task, especially if you are having a slow internet connection with you. Moreover, when it comes to Smartphone vendors, it will be a tough task to satisfy those customers, who want you to install standard apps in the device before they buy it. However, MoboRobo is an effective answer for both these issues. The section to manage applications in MoboRobo is quite helpful in installing multiple applications in your device right from your PC screen. Likewise, you have an option to transfer applications from phone memory to MicroSD card if you have both in your device. The most noticeable advantage of this application management section is that you will be able to save hell lot of data, as you will not have to spend your 3G data for downloading applications. To make these things simpler, MoboRobo consists of an integrated application store, from which users can download popular and useful apps in a matter of seconds or minutes.Contact Management & Messaging
If you have found contact management in device a tough task, this feature will help you a lot! In the contact section, you can find an option to edit contacts. When compared to your small screen, editing contacts using MoboRobo is an easy task, as you can use your keyboard and mouse to perform this task.

Just like the case of contacts, message section of MoboRobo is helpful in managing your SMSs right from your screen of your PC in such a way that you won’t have to get up and take Smartphone in order to reply to your texts. Replies will be available in the application instantaneously. Altogether, this section of MoboRobo is worth praising, indeed.

Enrich your Smartphone UI through MoboLive
MoboLive is an Android launcher that comes from same family of MoboRobo. If you have installed MoboLive in your device, you can use this Smartphone management tool to download and use MoboLive themes in your device. With no doubt, this section of MoboRobo is something superb as far as customizability of the Android launcher is a part of your concern.

Multiple Ways to Connect
It is not necessary that you have to connect your long USB cable to connect your Smartphone to PC, because it offers a feature to connect your PC to device using Wi-Fi connection. Obviously, it will be great if you are looking for fewer wires in your life.

Our Verdict
We were damn impressed by this application, as a great tool to manage your Smartphone! Particularly, we loved the intuitive user interface of MoboRobo. However, we are eager to know your opinion about this tool.

Data PHP and ASP

Data

Vanilla JS Browser Default Javascript

vanilla PHP and ASP

vanilla PHP and ASP

Start Vanilla – The Document Ready Event
Code runs after the browser finishes loading the document, including images and banner ads.

document.addEventListener(‘DOMContentLoaded’, function()
{
//JavaScript methods go here.
});

Click Event
Contains plain JavaScript code, here linkID is the ID name of anchor tag. You can prevent the default behavior by calling e.preventDefault();

document.addEventListener(‘DOMContentLoaded’, function()
{
//Click Event Code
document.querySelector(“#linkID”).addEventListener(“click”, function(e)
{
alert(“Click event triggered”);
e.preventDefault();
});});//HTML Code
<a href=”#” id=”linkID”>Click Event</a>

Hide & Show Div
The divBlock slowly disappears when clicked hideLink.

document.querySelector(“#hideLink”).addEventListener(“click”, function()
{
document.getElementById(‘divBlock’).style.display = ‘none’
});document.querySelector(“#showLink”).addEventListener(“click”, function()
{
document.getElementById(‘divBlock’).style.display = ”
});//HTML Code
<a href=”#” id=”hideLink”>Hide</a> — <a href=”#” id=”showLink”>Show</a>
<div id=”divBlock”>

</div>

Add & Remove Class
Applying and Removing a HTML Class.

CSS Code
You have to include following CSS code within the tag HEAD of the document

.hidden{display:none}

You can use following code with in the function HTMLElement.classList, this allows to add or remove the class of an element.

document.getElementById(‘divBlock’).classList.add(‘hidden’);

document.getElementById(‘divBlock’).classList.remove(‘hidden’);

//HTML Code
<a href=”#” id=”hideLink”>Hide</a> — <a href=”#” id=”showLink”>Show</a>
<div id=”divBlock”>

</div>

Toggle Class
This method simply toggles the visibility of elements, here the code is adding and removing the class hidden.

document.querySelector(“#toggle”).addEventListener(“click”, function()
{
document.getElementById(‘divBlock’).classList.toggle(‘hidden’);
});
//HTML Code
<a href=”#” id=”hideLink”>Toggle</a>
<div id=”divBlock”></div>

Mouse Over & Mouse Out
Changing the div behavior based on mouse moments.

HTML Code

<div class=”grid”></div>
<div class=”grid”></div>
<div class=”grid”></div>
<div class=”grid”></div>

JavaScript
Here grid is the class name of div tags. Using this calling the selected DOM element.

//MouseOver
[].forEach.call(document.querySelectorAll(“.grid”), function(el) {
el.addEventListener(“mouseover”, function() {
this.classList.add(‘hover’);
});
});//MouseOut
[].forEach.call(document.querySelectorAll(“.grid”), function(el) {
el.addEventListener(“mouseout”, function() {
this.classList.remove(‘hover’);
});
});

CSS Code

.grid
{
width:180px; height: 100px;
background-color:#333333;display: block;cursor:pointer;
float:left;margin-right: 10px
}
.hover
{
background-color: #cc0000 !important
}

Live POST Update and Delete Records with Vanilla JS

A simple demo project, you can instantly upload and delete news feed without refreshing the page.

HTML Code
Update box with news feed result. Live Demo

<textarea id=”updateText”></textarea>
<input type=”button” id=”updateButton” value=”POST” /><div id=”newsFeed”>
//Record One
<div class=”feed”>
The Wall Script http://thewallscript.com
<a href=”#” class=”delete”>X</a>
</div>
//Record Two
<div class=”feed”>
9lessons Blog http://9lessons.info
<a href=”#” class=”delete”>X</a>
</div>
……..
……..
……..
</div>

Ajax Post
Contains JavaScript code querySelector(“#updateButton”).addEventListener(“click”, function(){}updateButton is the ID name of the button. Usingdocument.getElementById(“updateText”).value; calling update textbox value. I did simplified a function called vanillaGetPost, you will find this in vanillaFunctions.js. Take a look at the Live Demo

//Update content.
var newsFeed=document.getElementById(‘newsFeed’);
document.querySelector(“#updateButton”).addEventListener(“click”, function()
{
var p = document.createElement(“div”),
newsFeed = document.getElementById(“newsFeed”),
content = document.getElementById(“updateText”).value;
var html ;var data=’update=’+content;
vanillaGetPost(‘POST’, ‘post.php’, data, function(data)
{
var updateText= document.getElementById(“updateText”);
html='<a class=”delete” href=”#” onclick=”deleteButton(this)” title=”Delete”>X</a>’;
p.innerHTML = data+html; //User update with delete button HTML code.
newsFeed.insertBefore(p, newsFeed.firstChild);
vanillaFadeEffect(‘fadeIn’,newsFeed.firstChild, 1000);
updateText.value=”;
updateText.focus();
});});

post.php
You have to write database connection for inserting update.

<?php
if($_POST[‘update’])
{
echo htmlentities($_POST[‘update’]);
// Write database connection here.
}
?>

Delete Records
Using this.parentNode calling parent DIV DOM element and applying fadeOut effect.

//Delete click event
[].forEach.call(document.querySelectorAll(“.delete”), function(el)
{
el.addEventListener(“click”, function() {
var parent = this.parentNode;
vanillaFadeEffect(‘fadeOut’,parent, 1000); //vanillaFunctions.js
});
});

Final JavaScript Code
You can include all of the code here.

<script src=”js/vanillaFunctions.js”></script>
<script>
document.addEventListener(‘DOMContentLoaded’, function()
{
//Textarea focus
window.onload = function() {
document.getElementById(“updateText”).focus();
};var newsFeed=document.getElementById(‘newsFeed’);//Delete click event
…….
…….
…….

//Update content.
…….
…….
…….

});

function deleteButton(id)
{
var parent = id.parentNode;
//Delete Ajax
vanillaFadeEffect(‘fadeOut’,parent, 1000);
}
</script>

Download the script, you will find out vinillaFunctions.js

vanillaGetPost Function
Ajax function for POST and GET methods.

function vanillaGetPost(type, url, data, success)
{
if(type==’GET’)
{
url=url+’?’+data;
data=”;
}
var r = window.XMLHttpRequest ? new XMLHttpRequest() : newActiveXObject(“Microsoft.XMLHTTP”);
r.open(type, url, true);
r.onreadystatechange = function () {
if (r.readyState > 3 && r.status === 200){
success(r.responseText);
}
};
r.setRequestHeader(‘X-Requested-With’, ‘XMLHttpRequest’);
r.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);
r.send(data);
return r;
}

vanillaFadeEffect Function
FadeIn and FadeOut animation effect.

function vanillaFadeEffect(effect, element, speed)
{
var A=0;
if(effect === ‘fadeOut’)
A=1;if ( ! element.style.opacity)
element.style.opacity = parseInt(A);var start = null;
window.requestAnimationFrame(function animate(timestamp) {
start = start || timestamp;
var progress = timestamp – start;

if(effect === ‘fadeOut’)
element.style.opacity = 1 – progress / speed;
else
element.style.opacity = progress / speed;

if (progress >= speed) {
if(effect === ‘fadeOut’)
element.style.display = ‘none’;
else
element.style.display = ”;

}
else
{
window.requestAnimationFrame(animate);
}
});

}

Improve Your Website loading Speed by Using Google Page Speed

Website loading speed can make a big impact the success of a website. In Google standards if your pages are loading slowly, you will lose the organic search traffic. Google is offering a powerful tool called PageSpeed Insights, that can test your website page speed and suggest you the instructions. Competitors hate each other, Google hates Facebook widgets such as Like Box, Facebook Page etc. This post will explain you how to solve all these Page Speed Insights problems.

Improve Your Website loading Speed by Using Google Page Speed PHP and ASP

Google Page Speed

 

Browser Notifications Display from Web Application

Browser desktop notification system, using this you can push notifications for event reminders, message information like whatsapp to desktop users in realtime from your web project. Very few line of JavaScript code, that can help you to interact with browser notification system. I have implemented this for 9lessons.info, you will find a most popular article notification for every 3 minutes. Take a quick look a the live demo.

browser PHP and ASP

Note: Try this demo with Chrome and Firefox

Start Browser Notification:
This code will initialize the browser notification system, read more about Vanilla JS(Plain JavaScript)

document.addEventListener(‘DOMContentLoaded’, function ()
{if (Notification.permission !== “granted”)
{
Notification.requestPermission();
}

});

Push Notification:
This function will help you to push notification data, here you have to modify iconURL. You can pass title, description and URL values.

function notifyBrowser(title,desc,url)
{if (Notification.permission !== “granted”)
{
Notification.requestPermission();
}
else
{
var notification = new Notification(title, {
icon:’http://YourWebsite.com/logo.png’,
body: desc,
});

/* Remove the notification from Notification Center when clicked.*/
notification.onclick = function () {
window.open(url);
};

/* Callback function when the notification is closed. */
notification.onclose = function () {
console.log(‘Notification closed’);
};

}
}

Firefox mozilla notification documentation

Demo Array:
The array contain most popular articles on 9lessons.info

var articles = [
[
“Vanilla JS Browser Default Java Script.”,
“http://www.9lessons.info/2015/09/vanilla-js-browser-default-java-script.html”
],
[
“Facebook Style Background Image Upload and Position Adjustment.”,
“http://www.9lessons.info/2015/02/facebook-style-background-image-upload.html”
],
[
“Create a RESTful services using Slim PHP Framework”,
“http://www.9lessons.info/2014/12/create-restful-services-using-slim-php.html”
],[
“Pagination with Jquery, PHP, Ajax and MySQL.”,
“http://www.9lessons.info/2010/10/pagination-with-jquery-php-ajax-and.html”
],
[
“Ajax Select and Upload Multiple Images with Jquery”,
“http://www.9lessons.info/2013/09/multiple-ajax-image-upload-jquery.html”
],
……
……
……
];

J query:
Contains javascipt code. $(“#notificationButton”).click(function(){}- notificationButtonis the ID name of input button.

<script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js”></script>
<script>
$(document).ready(function()
{
$(“#notificationButton”).click(function()
{
var x = Math.floor((Math.random() * 10) + 1); /* Random number between 1 to 10 */
var title =articles[x][0];
var desc =’Most popular article.’;
var url =articles[x][1];
notifyBrowser(title,desc,url);
return false;
});
});
</script>
//HTML Code
<input type=”button” id=”notificationButton” />

Vanilla JS:
Plain JavaScript

<script>
document.addEventListener(‘DOMContentLoaded’, function()
{
document.querySelector(“#notificationButton”).addEventListener(“click”,function(e)
{
var x = Math.floor((Math.random() * 10) + 1); /* Random number between 1 to 10 */
var title =articles[x][0];
var desc =’Most popular article.’;
var url =articles[x][1];
notifyBrowser(title,desc,url);
e.preventDefault();
});
});
</script>
//HTML Code
<input type=”button” id=”notificationButton” />

Set Timeout:
Contains simple JavaScript code, calls after 2 minutes. Here you can modify milliseconds values.

<script>
setTimeout(function(){
var x = Math.floor((Math.random() * 10) + 1); /* Random number between 1 to 10 */
var title =articles[x][0];
var desc =’Most popular article.’;
var url =articles[x][1];
notifyBrowser(title,desc,url);
}, 120000); //calls every 2 minutes
</script>

Using PHP Create Payment System with BrainTree PayPal

Are you working for e-commerce project? Then you should have a better and secure payment system. I suggest you setup you project with BrainTree API, it is very powerful and quick. This is accepting most commonly used Cards, PayPal, Android Pay and etc. This post will explain you how to design a cart and order system with BrainTree payment process using PHP and MySQL.

brainTree PHP and ASP

Take a quick look the live demo and try demo transaction.

Database Design:

To build the eCommerce system, you have to create four basic tables such as Users, Producs, Orders and Cart.

User Table:
User table contains all the users registration details.

CREATE TABLE Users(
user_id INT  PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50),
password VARCHAR(100),
email VARCHAR(100)
);

users PHP and ASP

Products Table:
This contains all of the product details.

CREATE TABLE Products(
product_id INT PRIMARY KEY AUTO_INCREMENT,
product_name VARCHAR(200),
product_desc TEXT,
price FLOAT
);

products PHP and ASP

Orders Table:
User successful orders store here with BrainTree status code.

CREATE TABLE Orders(
order_id INT PRIMARY KEY AUTO_INCREMENT,
user_id_fk INT,
created INT,
price FLOAT,
FOREIGN KEY(user_id_fk) REFERENCES Users(user_id)
);

order PHP and ASP

users  PHP and ASP

Cart Table:
This table contains all the user cart details. Cart order_id_fk is a foreign key, it references to Orders order_id. This will update once the user Order is successful.

CREATE TABLE Cart(
cart_id INT PRIMARY KEY AUTO_INCREMENT,
product_id_fk INT,
user_id_fk INT,
order_id_fk INT,
cart_status enum(‘0′,’1’) DEFAULT ‘0’,
FOREIGN KEY(product_id_fk) REFERENCES Products(product_id),
FOREIGN KEY(user_id_fk) REFERENCES Users(user_id),
FOREIGN KEY(order_id_fk) REFERENCES Orders(order_id)

cart PHP and ASP

cart  PHP and ASP

Payment Form & System Design

This project contains three folders called js,includes and uploads with PHP files.

braintree:
braintree.php //BrainTree library file
js
jquery.min.js
jquery.creditCardValidator.js
index.php
cardProcess.php
functions.php
db.php

Payment form contains Card Number, Card Name, Expiry Date and CVV(Secure Number).PaymentSystem PHP and ASPHTML5 Code:
Simple HTML5 code

<form method=”post”  id=”paymentForm”>
Payment details
<ul>

<li>
<label>Card Number </label>
<input type=”text” name=”card_number” id=”card_number”  maxlength=”20″ placeholder=”1234 5678 9012 3456″/>
</li>
<li>
<label>Name on Card</label>
<input type=”text” name=”card_name” id=”card_name” placeholder=”Srinivas Tamada”/>
</li>
<li class=”vertical”>

<ul>
<li>
<label>Expires</label>
<input type=”text” name=”expiry_month” id=”expiry_month” maxlength=”2″ placeholder=”MM” />
<input type=”text” name=”expiry_year” id=”expiry_year” maxlength=”2″ placeholder=”YY” />
</li>
<li>
<label>CVV</label>
<input type=”text” name=”cvv” id=”cvv” maxlength=”3″ placeholder=”123″ />
</li>
</ul>

</li>
<li>
<input type=”submit” id=”paymentButton” value=”Proceed” disabled=”true” class=”disable”>
</li>
</ul>
</form>
<div id=”orderInfo”></div>

CSS Code:

*{margin: 0px; padding:0px;}
ul {list-style: none;}
label{padding:8px 0px 8px 0px;}
#paymentForm label
{
color: #555;
display: block;
font-size: 14px;
font-weight: 400;
}
#paymentForm input[type=text]
{
background-color: #FFFFFF;
border: 1px solid #E5E5E5;
color: #333333;
display: block;
font-size: 18px;
height: 32px;
padding: 0 5px;
width: 275px;
}
#paymentForm li {margin: 8px 0;}
#orderInfo{display:none}
.disable{opacity: 0.2}
.vertical li
{
float: left;
width: 140px;
}

JavaScript:
Validating the payment form using Regular Expressions.

<script src=”js/jquery.min.js”></script>
<script src=”js/jquery.creditCardValidator.js”></script>
<script>
$(document).ready(function()
{
/* Form Validation */
$(“#paymentForm input[type=text]”).on(“keyup”,function()
{
var cardValid=$(“#card_number”).attr(‘rel’);
var C=$(“#card_name”).val();
var M=$(“#expiry_month”).val();
var Y=$(“#expiry_year”).val();
var CVV=$(“#cvv”).val();
var expName =/^[a-z ,.’-]+$/i;
var expMonth = /^01|02|03|04|05|06|07|08|09|10|11|12$/;
var expYear = /^16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31$/;
var expCVV=/^[0-9]{3,3}$/;

if(cardValid>0 && expName.test(C) && expMonth.test(M) && expYear.test(Y)
&& expCVV.test(CVV) && parseInt(cardCheck)>0)
{
$(‘#paymentButton’).prop(‘disabled’, false);
$(‘#paymentButton’).removeClass(‘disable’);
}
else
{
$(‘#paymentButton’).prop(‘disabled’, true);
$(‘#paymentButton’).addClass(‘disable’);
}
});

/* Card Validation */
cardValidate();

/*Payment Form */
$(“#paymentForm”).submit(function()
{
//…….
});

});
</script>

Card Validation:
Credit Card Validation using jquery.validateCreditCard plugin.

/* Credit Card Type Check */
function cardValidate()
{
$(‘#card_number’).validateCreditCard(function(result)
{
var N=$(this).val();
var C=$(this).attr(“class”);
$(this).attr(“class”,””);
if(result && N.length>0)
{
$(this).addClass(result.card_type.name);

if(result.valid && result.length_valid && result.luhn_valid)
{
$(this).addClass(‘valid’);
$(this).attr(“rel”,”1″);
}
else
{
$(this).attr(“rel”,”1″);
}

}
else
{
$(this).removeClass(C);
}
});
}

Ajax Payment Process:
BrainTree Payment process with Jquery Ajax, here $(this).serialize() get all the form input values and posting to cardProcess.php. Once order is successful, use will get the Order status message.

/*Payment Form */
$(“#paymentForm”).submit(function()
{
var datastring = $(this).serialize();
$.ajax({
type: “POST”,
url: “cardProcess.php”,
data: datastring,
dataType: “json”,
beforeSend: function(){  $(“#paymentButton”).val(‘Processing..’) },
success: function(data)
{
$.each(data.OrderStatus, function(i,data)
{
var HTML;
if(data)
{
$(“#paymentGrid”).slideUp(“slow”);
$(“#orderInfo”).fadeIn(“slow”);

if(data.status == ‘1’)
{
HTML=”Order <span>”+data.orderID+”</span> has been created successfully.”;
}
else if(data.status == ‘2’)
{
HTML=”Transaction has been failed, please use other card.”;
}
else
{
HTML=”Card number is not valid, please use other card.”;
}

$(“#orderInfo”).html(HTML);
}
});
},
error: function(){ alert(‘Network Error’); }
});
return false;
});

BrainTree Integration:

Create a sandbox account at sandbox.braintreegateway.com for testing process.

braintreelogin PHP and ASPGo to Account -> My User scroll down you will find API keys.
button PHP and ASPYou will find merchantId, publicKey and privateKey
keys PHP and ASP

cardProcess.php:
Here you have to modify with your BrainTree merchandID, pulicKey and privateKey. This is update Orders table, once the transaction is successful. Always maintain/storecart total price value in session. Once testing is done, you can modify environment value from sandbox to production.

<?php
include ‘db.php’;
include ‘functions.php’;
$session_price =$_SESSION[‘session_price’]; //Cart Total Price
if($_SERVER[“REQUEST_METHOD”] == “POST” )
{
$card_number=str_replace(“+”,””,$_POST[‘card_number’]);
$card_name=$_POST[‘card_number’];
$expiry_month=$_POST[‘expiry_month’];
$expiry_year=$_POST[‘expiry_year’];
$cvv=$_POST[‘cvv’];
$expirationDate=$expiry_month.’/’.$expiry_year;

require_once ‘braintree/Braintree.php’;
Braintree_Configuration::environment(‘sandbox’); // Change to production
Braintree_Configuration::merchantId(‘Merchant_ID’);
Braintree_Configuration::publicKey(‘Public_Key’);
Braintree_Configuration::privateKey(‘Private_Key’);
//BrainTree payment process
$result = Braintree_Transaction::sale(array(
‘amount’ => $price,
‘creditCard’ => array(
‘number’ => $card_number,
‘cardholderName’ => $card_name,
‘expirationDate’ => $expirationDate,
‘cvv’ => $cvv
)
));

if ($result->success)
{
if($result->transaction->id)
{
$braintreeCode=$result->transaction->id;
updateUserOrder($braintreeCode,$session_user_id,$session_price); //Order table update.
}
}
else if ($result->transaction)
{
echo ‘{“OrderStatus”: [{“status”:”2″}]}’;
}
else
{
echo ‘{“OrderStatus”: [{“status”:”0″}]}’;
}
}
?>


Update User Order:
This will update orders table, based on the BrainTree status code. Cart table status will change 0 to 1 with order id.

<?php
function updateUserOrder($braintreeCode,$session_user_id,$session_price)
{
$db = getDB();
$sql = “INSERT INTO Orders(user_id_fk,created,braintreeCode)VALUES(:user_id,:created,:braintreeCode)”;
$stmt = $db->prepare($sql);
$stmt->bindParam(“user_id”, $session_user_id);
$time=time();
$stmt->bindParam(“created”, $time);
$stmt->bindParam(“braintreeCode”, $braintreeCode);
$stmt->execute();

$sql1 = “SELECT order_id FROM Orders WHERE user_id_fk=:user_id ORDER BY order_id DESC LIMIT 1”;
$stmt1 = $db-> prepare($sql1);
$stmt1-> bindParam(“user_id”, $session_user_id);
$stmt1-> execute();
$OrderDetails = $stmt1->fetchAll(PDO::FETCH_OBJ);
$order_id=$OrderDetails[0]->order_id;

$sql2 = “UPDATE Cart SET order_id_fk=:order_id,cart_status=’1′,price=:price WHERE cart_status=’0′ AND user_id_fk=:user_id”;
$stmt2 = $db-> prepare($sql2);
$stmt2-> bindParam(“user_id”, $session_user_id);
$stmt2-> bindParam(“order_id”, $order_id);
$stmt2-> bindParam(“price”, $session_price);
$stmt2-> execute();
$db = null;
echo ‘{“OrderStatus”: [{“status”:”1″, “orderID”:”‘.$order_id.'”}]}’;
}
?>


Get User Cart Details:
Getting card details based on user session id.

<?php
function getUserCartDetails($session_user_id)
{
$db = getDB();
$sql = “SELECT P.product_name,P.price FROM Users U, Cart C, Products P WHERE U.user_id=C.user_id_fk AND P.product_id = C.product_id_fk AND C.user_id_fk=:user_id AND C.cart_status=’0′”;
$stmt = $db->prepare($sql);
$stmt->bindParam(“user_id”, $session_user_id);
$stmt->execute();
$getUserCartDetails = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
return $getUserCartDetails;
}
?>
db.php:
You have to modify username, password and databaseName values. Make sure enable PDO extension in PHP.ini.
<?php
function getDB() {
$dbhost=”localhost”;
$dbuser=”username”;
$dbpass=”password”;
$dbname=”databaseName”;
$dbConnection = new PDO(“mysql:host=$dbhost;dbname=$dbname”, $dbuser, $dbpass);
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $dbConnection;
}/* User Sessions */
session_start();
$session_user_id=$_SESSION[‘user_id’];

Note: Once your testing is done, create a BrainTree production account and modify the key details.

Importing Your Database Tables

Importing Database Tables

Most new scripts come with a built-in installer. All that is resuired to pose it, is to alluviation the ‘lay.php’ author in your browser and participate your database information in the represent that is provided. When the info is submitted, the playscript creates all database tables automatically. Helping of cake. Alas, rattling ofttimes there’s no such installer included, and you’ll hit to create the database tables manually. – don’t headache – there’s nothing to it, When this is the human, a isolated database file faculty be included in the script’s folder (instruction: ‘.sql’). Unremarkably it’s titled ‘db.sql’, but this can be anything. Halt your script’s beginning drill to mature out. This is the record you poorness to meaning into your meaningless database to make the database tables. To conceptualise out how to do this for Importing Database Tables,

Still on the same page in your cPanel, click ‘phpMyAdmin’ for Importing Database Tables.

Importing Your Database Tables PHP and ASP

Importing Your Database Tables

This will open phpMyAdmin in a new window to Importing Database Tables.:

Importing your Database PHP and ASP

Importing Your Database

For  Importing Database Tables > In the left drop down menu, select the database you’ve just created. The database name will be followed by ‘(0)’, since you haven’t created any tables yet. The nigh compose instrument impart the masses content: ‘No tables plant in database’. In the reactionary build, stop the ‘Import’ tab. Click the ‘Browse’ button. Browse to your script’s folder, select the ‘db.sql’*-file and click ‘Open’.

 For Importing Database Tables Just Click ‘Go’ to start the import .

Importing Your Database Tables PHP and ASP

Importing Your Database Tables

Importing Database Tables> When your intend has been productive, your tables instrument be created. In the port redact, you’ll see the merchandise of tables that feature been created happen behindhand your database repute, and you’ll see a move of all those tables below that. You can close both phpMyAdmin and cPanel and go on installing your script for Importing Database Tables.