Fetching data from a CSV file using PHP

To open a CSV file, start by opening the file by using PHP function fopen.

After opening the file (creating file pointer), cycle through the content using fgetcsv function. This function reads the file line by line and parse it based on fields in CSV.

Continue reading Fetching data from a CSV file using PHP

Ignoring SSl certificate when debugging in Android WebView

During development process if you are accessing a web page with SSL certificate you could either get a “Blank Page” or “Page Not Found” error.
To prevent this from happening while developing your app, simply override “onReceivedSslError” of WebViewClient object and continue the execution process.

By doing this, the SSL is being completely ignored and therefore could have a serious result if you forgot to remove the code after development and push the code into production.
To prevent that from happening simply check the build variants.

Adding shake effect in Android

To add a shake effect to a textbox when an error occurs, first add the following 2 XML files in your anim folder

< -- ../main/res/anim/shake.xml -->
1) Control how fast or slow the shake should be in this file.
2) Control how far the shake go from left to right.

Continue reading Adding shake effect in Android

Validating an email address with PHP

Steps to validate an email address:

  1. Sanitizing the email address:
    • strtolower($emailAddress);
    • filter_var($emailAddress, FILTER_SANITIZE_EMAIL); // remove bad characters from the email.
  2. Validating the email adress:
    • filter_var($emailAddress, FILTER_VALIDATE_EMAIL);

Note: For email addresses containing Internationalized Domain Names (IDN) you need to convert it to punycode before validating the email address.

Installing LAMP stack (Apache, MySql, PHP) in Ubuntu

Notes;

  • The steps in this tutorial require the user to have root permission.
  • There are many different ways to achieve the same result but I found the following steps simpler than other methods.
  • This tutorial has been tested on a fresh copy of Ubuntu 14.04 on a Virtual Machine (VM)
  • To restart apache web server you can run the following command:
  • sudo /etc/init.d/apache2 restart

Continue reading Installing LAMP stack (Apache, MySql, PHP) in Ubuntu