How to call javascript function instead of href in HTML

call javascript function in href

<a href="javascript:void(0);" onclick="foo(2367,146986,2);">


<a href="javascript:foo(2367,146986,2);">
Tagged with: , ,
Posted in HTML, Javascript

Top 10 Programming Languages in 2014

1. Java


What it is: Java is a class-based, object-oriented programming language developed by Sun Microsystems in the 1990s. It’s one of the most in-demand programming languages, a standard for enterprise software, web-based content, games and mobile apps, as well as the Android operating system. Java is designed to work across multiple software platforms, meaning a program written on Mac OS X, for example, could also run on Windows.


2. C Language

C Language

What it is: A general-purpose, imperative programming language developed in the early ’70s, C is the oldest and most widely used language, providing the building blocks for other popular languages, such as C#, Java, JavaScript and Python. C is mostly used for implementing operating systems and embedded applications.

Because it provides the foundation for many other languages, it is advisable to learn C (and C++) before moving on to others.


3. C++

C Plus Plus

What it is: C++ is an intermediate-level language with object-oriented programming features, originally designed to enhance the C language. C++ powers major software like Firefox, Winamp and Adobe programs. It’s used to develop systems software, application software, high-performance server and client applications and video games.


4. C#

C Sharp

What it is: Pronounced “C-sharp,” C# is a multi-paradigm language developed by Microsoft as part of its .NET initiative. Combining principles from C and C++, C# is a general-purpose language used to develop software for Microsoft and Windows platforms.


5. Objective-C


What it is: Objective-C is a general-purpose, object-oriented programming language used by the Apple operating system. It powers Apple’s OS X and iOS, as well as its APIs, and can be used to create iPhone apps, which has generated a huge demand for this once-outmoded programming language.


6. PHP


What it is: PHP (Hypertext Processor) is a free, server-side scripting language designed for dynamic websites and app development. It can be directly embedded into an HTML source document rather than an external file, which has made it a popular programming language for web developers. PHP powers more than 200 million websites, including WordPress, Digg and Facebook.


7. Python


What it is: Python is a high-level, server-side scripting language for websites and mobile apps. It’s considered a fairly easy language for beginners due to its readability and compact syntax, meaning developers can use fewer lines of code to express a concept than they would in other languages. It powers the web apps for Instagram, Pinterest and Rdio through its associated web framework, Django, and is used by Google, Yahoo! and NASA.


8. Ruby


What it is: A dynamic, object-oriented scripting language for developing websites and mobile apps, Ruby was designed to be simple and easy to write. It powers the Ruby on Rails (or Rails) framework, which is used on Scribd, GitHub, Groupon and Shopify. Like Python, Ruby is considered a fairly user-friendly language for beginners.


9. JavaScript


What it is: JavaScript is a client and server-side scripting language developed by Netscape that derives much of its syntax from C. It can be used across multiple web browsers and is considered essential for developing interactive or animated web functions. It is also used in game development and writing desktop applications. JavaScript interpreters are embedded in Google’s Chrome extensions, Apple’s Safari extensions, Adobe Acrobat and Reader, and Adobe’s Creative Suite.


10. SQL


What it is: Structured Query Language (SQL) is a special-purpose language for managing data in relational database management systems. It is most commonly used for its “Query” function, which searches informational databases. SQL was standardized by the American National Standards Institute (ANSI) and the International Organization for Standardization (ISO) in the 1980s.

Tagged with: , , , , , , , , , , , , , ,
Posted in APIs, ASP, CSS, Frameworks, Giveaway Stuff, HTML, Javascript, PHP, Scripts, Snippets, SQL, Uncategorized

How to Set Up PayPal Integration with PHP & MySQL

PayPal is the most popular payment service on the web so being able to integrate your website with PayPal’s Instant Payment Notification Service (IPN) is essential if you need to process payments through your website.

There are 3 main parts to the PayPal IPN system.

  1. A webpage that initiates a request to PayPal to make a payment.
  2. A PHP page on your webserver that PayPal calls to notify you that payment has been made.
  3. A webpage that confirms the above payment and continues on to the next phase of your web application, such as a ‘Thank You’ page.

Parts 1 and 3 are accessible by customers on your website. Part 2 is only visible to PayPal.  The diagram below illustrates the interaction between your customer, PayPal and your website.

PayPal Interaction

The following steps break down each part of the process into easy to follow chunks, it is assumed that you have knowledge of PHP and MySQL.

Step 1 – Setup PayPal Account

Sign up for a PayPal account if you don’t already have one. Select an appropriate account type, either Personal or Business.

Once you have a registered PayPal account your account must be setup correctly to use IPN.

Select ‘edit profile’ from your PayPal account and check the following settings.

  • Under ‘Selling Preferences’ >> ‘Instant Payment Notification Preferences’
  • Under ‘Selling Preferences’ >> ‘payment receiving preferences’
    • Block payments from users who pay with echeck. (This is because these will not be instant payments)
  • Under ‘account information’ >> ‘email’
    • Note down your primary email address. This email will be visible to users so make it a professional one. User’s may feel apprehensive about sending money to an e-mail address with the domain ‘’ or ‘’ etc…

Step 2 – Simple HTML Form

Your website must now send all the required values to PayPal so that the payment can be processed.

The following code example demonstrates a basic form that we will use to send the values:

cmd” type=”hidden” value=”_xclick” />

The business name, price, submit type, notify URL and other sensitive values will be sent during the next step.

A full list of the values to send can be found at the PayPal website under the title “A Sample IPN Message and Response”.

Step 3 – Payments.php (The Request)

The payment.php page will be used to handle the outgoing request to PayPal and also to handle the incoming response after the payment has been processed.

The following sample code shows the querystring being constructed before it is posted to PayPal. Here you can specify the following values:

  • Business ($paypal_email) – Enter the email address of your PayPal account.
  • Item name ($item_name) – The name of the item being purchased.
  • Amount ($item_amount) – The price of the item.
  • Return ($return_url) – The address to return to after a successful payment.
  • Cancel Return ($cancel_url) – the address to return to after a cancelled payment.
  • Notify URL ($notify_url) – The address of the payments.php page on your website.
  • Custom – Any other data to be sent and returned with the PayPal request.
// Database variables
$host = "localhost"; //database location
$user = ""; //database username
$pass = ""; //database password
$db_name = ""; //database name

// PayPal settings
$paypal_email = '';
$return_url = '';
$cancel_url = '';
$notify_url = '';

$item_name = 'Test Item';
$item_amount = 5.00;

// Include Functions

//Database Connection
$link = mysql_connect($host, $user, $pass);

// Check if paypal request or response
if (!isset($_POST["txn_id"]) && !isset($_POST["txn_type"])){

    // Firstly Append paypal account to querystring
    $querystring .= "?business=".urlencode($paypal_email)."&";

    // Append amount& currency (£) to quersytring so it cannot be edited in html

    //The item name and amount can be brought in dynamically by querying the $_POST['item_number'] variable.
    $querystring .= "item_name=".urlencode($item_name)."&";
    $querystring .= "amount=".urlencode($item_amount)."&";

    //loop for posted values and append to querystring
    foreach($_POST as $key => $value){
        $value = urlencode(stripslashes($value));
        $querystring .= "$key=$value&";

    // Append paypal return addresses
    $querystring .= "return=".urlencode(stripslashes($return_url))."&";
    $querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&";
    $querystring .= "notify_url=".urlencode($notify_url);

    // Append querystring with custom field
    //$querystring .= "&custom=".USERID;

    // Redirect to paypal IPN

    // Response from PayPal

Step 4 – Payments.php (The Response)

The next part of the payments.php page handles the response from PayPal. The response is re-assigned to variables and then posted back to PayPal for verification using fsockopen.

If the response is VERIFIED then a validation check can be performed. The check_txnid and check_price functions are called to check that the correct Transaction ID and Price have been returned. The updatePayments function can finally be called to store the details of the payment in the payments table (Step 6).

// Database variables
$host = "localhost"; //database location
$user = ""; //database username
$pass = ""; //database password
$db_name = ""; //database name

// PayPal settings
$paypal_email = '';
$return_url = '';
$cancel_url = '';
$notify_url = '';

$item_name = 'Test Item';
$item_amount = 5.00;

// Include Functions

//Database Connection
$link = mysql_connect($host, $user, $pass);

// Check if paypal request or response
if (!isset($_POST["txn_id"]) && !isset($_POST["txn_type"])){
    // Request from step 3

    // Response from Paypal

    // read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-validate';
    foreach ($_POST as $key => $value) {
        $value = urlencode(stripslashes($value));
        $value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix
        $req .= "&$key=$value";

    // assign posted variables to local variables
    $data['item_name']          = $_POST['item_name'];
    $data['item_number']        = $_POST['item_number'];
    $data['payment_status']     = $_POST['payment_status'];
    $data['payment_amount']     = $_POST['mc_gross'];
    $data['payment_currency']   = $_POST['mc_currency'];
    $data['txn_id']             = $_POST['txn_id'];
    $data['receiver_email']     = $_POST['receiver_email'];
    $data['payer_email']        = $_POST['payer_email'];
    $data['custom']             = $_POST['custom'];

    // post back to PayPal system to validate
    $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

    $fp = fsockopen ('ssl://', 443, $errno, $errstr, 30);

    if (!$fp) {
        // HTTP ERROR
    } else {
                mail('', '0', '0');
        fputs ($fp, $header . $req);
        while (!feof($fp)) {
            $res = fgets ($fp, 1024);
            if (strcmp ($res, "VERIFIED") == 0) {

                // Validate payment (Check unique txnid & correct price)
                $valid_txnid = check_txnid($data['txn_id']);
                $valid_price = check_price($data['payment_amount'], $data['item_number']);
                // PAYMENT VALIDATED & VERIFIED!
                if($valid_txnid && $valid_price){
                    $orderid = updatePayments($data);
                        // Payment has been made & successfully inserted into the Database
                        // Error inserting into DB
                        // E-mail admin or alert user
                    // Payment made but data has been changed
                    // E-mail admin or alert user

            }else if (strcmp ($res, "INVALID") == 0) {

                // E-mail admin or alert user
    fclose ($fp);

Step 5 – Functions.php

The payments.php page calls upon a number of functions used to validate the returned data and store the response in the database.

// functions.php
function check_txnid($tnxid){
    global $link;
    return true;
    $valid_txnid = true;
    //get result set
    $sql = mysql_query("SELECT * FROM `payments` WHERE txnid = '$tnxid'", $link);
    if($row = mysql_fetch_array($sql)) {
        $valid_txnid = false;
    return $valid_txnid;

function check_price($price, $id){
    $valid_price = false;
    you could use the below to check whether the correct price has been paid for the product
    if so uncomment the below code

    $sql = mysql_query("SELECT amount FROM `products` WHERE id = '$id'");
    if (mysql_numrows($sql) != 0) {
        while ($row = mysql_fetch_array($sql)) {
            $num = (float)$row['amount'];
            if($num == $price){
                $valid_price = true;
    return $valid_price;
    return true;

function updatePayments($data){
    global $link;
        $sql = mysql_query("INSERT INTO `payments` (txnid, payment_amount, payment_status, itemid, createdtime) VALUES (
                '".$data['txn_id']."' ,
                '".$data['payment_amount']."' ,
                '".$data['payment_status']."' ,
                '".$data['item_number']."' ,
                '".date("Y-m-d H:i:s")."'
                )", $link);
    return mysql_insert_id($link);

Step 6 – Setting Up The Payments Table

To store payment details in the database a payments table must be created in your database. The following MYSQL code will create a payments table.

  `txnid` varchar(20) NOT NULL,
  `payment_amount` decimal(7,2) NOT NULL,
  `payment_status` varchar(25) NOT NULL,
  `itemid` varchar(25) NOT NULL,
  `createdtime` datetime NOT NULL,
  PRIMARY KEY (`id`)

Step 7 – Sandbox Testing / Going Live

PayPal Sandbox offers all of the functionality of PayPal, but the information involves all “Fake accounts” created by the developer. You can create fake buyer and fake seller profiles, then test your PayPal integration through your development website.

During the testing phase of the development process the PayPal links should be prefixed to You can visit the PayPal Developer website and sign up for a free PayPal Sandbox account

Once the payment process is ready to be used by real customers you will need to remove the sandbox from each PayPal link to

That’s it; you’re ready to start taking payments online through your website.

Tagged with: , , , , ,
Posted in PHP

How to enable rewrite module in XAMPP, WAMP and Apache

If you are using XAMPP or WAMP as your web server, you may face a common problem that is the rewrite module (mod_rewrite) does not work properly. It is because the rewrite module is not enabled by default in Apache’s configuration settings. But you can enable it manually by doing few simple steps:

  1. Open apache’s configuration file using your favorite text editor. The configuration file generally locates at:{apache_dir}/conf/httpd.conf
    If you are using XAMPP or WAMP package then you will find the file at:{xampp_dir}/apache/conf/httpd.conf
  2. Search for the following string:#LoadModule rewrite_module modules/mod_rewrite.soand uncomment it (remove the ‘#’ sign).
  3. Now search for another string AllowOverride None and replace it by AllowOverride All
  4. Finally save the changes, close your text editor and restart your apache server.

That’s all. :)


Tagged with: , , , , , , ,
Posted in PHP

IIS web.config How to redirect to

On Windows Server 2008 IIS 7.5

You can add rewrite rule in web.config file to redirect to

Replace with your domain

<!--?xml version="1.0"?>
  For more information on how to configure your ASP.NET application, please visit

<rule name="Canonical host name">
<match url="^(.*)" />
<add input="{HTTP_HOST}" pattern="^www\.domain\.com$" negate="true" />
<action type="Redirect" url="{R:1}" />
Tagged with: , , , , ,
Posted in ASP

HTML5 vs. Native Mobile Applications – Who do you Back?

Recently, we have seen a surge in the ongoing debate of whether it is best to develop mobile applications using HTML5 in some responsive framework manner or as a standalone bespoke-application.

HTML5 Mobile Applications vs. Native Mobile Applications

Generally, the answer is completely dependant on an individual project specification and brief although according to a recent Gartner report amongst 478 developers in North America and Europe, 22% of developers are developing hybrid apps, 24% on mobile web-applications and 41% on native app development such as iOS or Android specific applications.

Consequently, the heated topic often leaves developers opting for one over the other, mostly down to personal preferences. However, developers are shifting more towards the significance of striking a balance between the ability to monetise their applications whilst providing a high quality, easily-understandable and friendly user experience.

The Difference in Development

Developing native applications is generally considered much easier than finding the perfect balance on a responsive website that suits all types of devices. Languages and their supported IDE’s, such as Objective-C and XCode, make rapid development of native mobile applications much easier to accomplish and typically, developers don’t require much understanding of the underlying principles of the platform and its language.

Developers will often find that bug-fixing in native applications is easier than identifying issues on hybrid or HTML5-specific apps. This is mostly due to the complex debugging tools an IDE will provide you with that can pinpoint the exact root and cause of a bug. However, the major disadvantage in development is the fact that every application is native to its OS, device and platform, so developers often need to release multiple versions to accommodate the wide spread of devices.

In contrast, HTML5 developers will often take a different approach with the development. Typically, the developers are familiar with creating web technologies, giving them the advantage that they have a wider skill base to approach the task, without necessarily needing to learn a new IDE or programming language. Also, HTML5 mobile applications can run on any device or platform that has access to a web browser, immediately increasing the development reach – although – you may end up spending equally as much time testing your application – similar to native applications per device testing – you’ll need to cross-browser check your application. With there being an enormous amount of mobile and tablet devices, you’ll need to strike a balance on the devices you want to target and those you decide not to officially support.

Delivering User Experience to Generate a Revenue Stream

If we look through a consumers perspective, monetisation and development are two different things entirely. If we take a game as an example, you’ll only be focusing initially on the visual appeal of the application and, once we have purchased the game, how easy it is to play. However, as a developer, you may set in stone additional ways your consumers can turn your app into a revenue stream – are you offering in-app purchases? If you’re using HTML5, how will you integrate the equivalent of in-app purchases to your users, what checkout will you integrate into, is there a charge?

With any application, you want to create something that’s visually appealing, powerful and has a look and feel that’s symbolic to your corporate branding – therefore the user interface (UI) design of your application is hugely important.

With native mobile applications, you have access to higher graphic rendering and better synchronisation that’ll often aid your consumers appeal knowing that the device they’re on can do more than a standalone static HTML5 web-application. Additionally, developing native mobile applications means consumers can take advantage of their devices hardware – you can integrate the camera, GPS, volume, search buttons, etc. directly into your application that can potentially update the UI. Of course this goes without saying, HTML5 has come a long way and developers have a batch of new API’s that allow them to access the devices battery, geolocation, though you’ll have to put the effect in to get these working on par with the native mobile application.

When it comes to HTML5, developers have the normal flexibility they have when designing websites. CSS3 allows you to control pretty much every aspect of your website, and, if it doesn’t support a selector you’re after you can always fallback to a Javascript/jQuery selector. However, if we are addressing games, HTML5 doesn’t provide the same level of sophistication we’d hope to implement (unless you get really dirty programming) although with HTML5 you can put together simple, streamline applications that are low in development cost, yet high in revenue. The less sophisticated an application design and development is, the more profit you’re likely to make and thus potentially the more preferable the option?


Performance is always a huge factor to the success of any application. Consumers want responsive (in the aspect of load times and non-sluggish behaviour), adaptive and flexible applications that are able to handle a high load of requests – in case the person using the application gets ‘click happy’ – you don’t just want the application to crash and ungraciously handle the issues.

Depending on the type of application you’re looking to develop will assess whether or not you need access to an Internet connection which can be the downfall of most web-applications. How do you access it when you’re stuck in a mobile signal dead spot? Native applications will typically aggressively cache all their content and resources, meaning you’re able to continue using the application when you go offline and simply synchronise all your data when you re-connect either through 3G, 4G or Wi-Fi. However, as applications become more socially connected, both types of application will suffer under the wrath of needing an ‘always connected’ device – even with native applications, there is typically something happening in the background, some form of asynchronous update.

Another factor you’ll want to consider is that of memory and optimisation. You always want to develop any application in the strictest standard possible. You want to ensure you’re not leaking memory on native mobile applications, and ensure you’re not hogging shared memory on web-applications. Native applications such as iOS applications have a huge selection of tools and utilities that able you to debug and test your application for leaks and assignment issues. Thankfully, with HTML5 web-applications you tend to bi-pass this issue altogether, or at least they’re not as major as most tablets, laptops and PC’s will have more resources available.

Overall, it’s valid to say that both native and web applications have an equal share of pitfalls when it comes to performance so it simply comes down to a matter of preference and what you know you’ll be able to manage and refactor when an issue does arise.

A Quick Roundup

As unhelpful as it may seem, I believe a conclusion on the matter is entirely opinion based and therefore biased towards what any developer prefers. If you’re well-versed in Objective-C, C, C++ or Java if you’re not, you may want to learn Objective-C – then you’d most likely enjoy and thus prefer developing native applications. Whilst if you’re already a web designer or developer, you’ll tend to sway towards the HTML5 responsive web-application approach – after all, that’ll cut down your development and provide a platform that can be accessed on all devices that have access to a web browser.

What Next?

Every great mobile application, whether HTML5 based or native to any platform, will require an API. We’ve put together some great articles on designing a REST API server for your mobile application and some programming guidelines for setting up and implementing OAuth2 in Objective-C (for iOS apps).

Tagged with: , ,
Posted in HTML, Uncategorized

Get every new post delivered to your Inbox.

Join 129 other followers