FacebookTwitter

Redirect Page Using PHP

By on Oct 31, 2014 in Interesting, PHP

Enmanuel Corvo

Enmanuel Corvo

Software Engineer at LiveAnswer
Enmanuel Corvo is a Software Engineer experienced in Web Applications Development. Huge fan of Wordpress and an active plug-in author who enjoys writing code and blog posts about anything related to technology. Enmanuel also helps provide cloud solutions and software integrations to enterprise and small business.
Enmanuel Corvo

Latest posts by Enmanuel Corvo (see all)

PHP Page Redirect Using The Header Function As a webmaster you have most likely come across a few redirects. Sometimes you need to simply redirect to another page, rather than changing links, which could be painful if you have too many. Fortunately redirects a fairly simple. And using PHP you can redirect to anywhere very easy. There are many ways to achieve a redirect. I will discuss the one that I always use in PHP, the header function. This method is considered to be the fastest and most reliable way to achieve a page redirect. To use this PHP page redirect method is very easy, all you will need to do is point to the new location (the redirect) inside the header function. Take a look a the code sample bellow: ?View Code PHP1 2 3 /* Redirect browser */ header("Location: http://www.webtricksandtreats.com"); exit(); It is always good practice to include exit() after to prevent any code that follows from being executed. Also, it is very important that the is nothing above the PHP header function that will be doing the redirect. There should not be any output abve it whatsoever, else it is very likely to fail. This is a common mistake to have empty spaces or lines above the header function. This will give you endless headaches, as you will try to figure out why a simple PHP page redirect is not working as it should, not taking into consideration an empty line above it. In addition, this...

Export Array to CSV – PHP

By on Aug 29, 2014 in PHP

Enmanuel Corvo

Enmanuel Corvo

Software Engineer at LiveAnswer
Enmanuel Corvo is a Software Engineer experienced in Web Applications Development. Huge fan of Wordpress and an active plug-in author who enjoys writing code and blog posts about anything related to technology. Enmanuel also helps provide cloud solutions and software integrations to enterprise and small business.
Enmanuel Corvo

Latest posts by Enmanuel Corvo (see all)

Export to CSV – PHP CSV (comma-separated values) is the most widely supported format for transferring tabular data. Exporting data in CSV format is very common in web applications. This simple example will help you get started with CSV and PHP. The main goal is to create a simple way to export data from your website or web application into a CSV that can be downloaded by the user. The Code ?View Code PHP1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 <?php function convert_to_csv($input_array, $output_file_name, $delimiter) { /** open raw memory as file, no need for temp files, be careful not to run out of memory thought */ $f = fopen('php://memory', 'w'); /** loop through array */ foreach ($input_array as $line) { /** default php csv handler **/ fputcsv($f, $line, $delimiter); } /** rewrind the "file" with the csv lines **/ fseek($f, 0); /** modify header to be downloadable csv file **/ header('Content-Type: application/csv'); header('Content-Disposition: attachement; filename="' . $output_file_name . '";'); /** Send file to browser for download */ fpassthru($f); } /** Array to convert to csv */ $array_to_csv = Array( Array(12566, 'Enmanuel', 'Corvo' ), Array(56544, 'John', 'Doe' ), Array(78550, 'Mark', 'Smith' ) ); convert_to_csv($array_to_csv, 'report.csv', ','); The Explanation [show_resp_ad] The function convert_to_csv($input_array, $output_file_name, $delimiter) export to csv by taking in a PHP Array ($input_array) as its first parameters and converts it into...

How to Make a Phone Call from your Computer – Getting started with Twilio Voice

By on Aug 14, 2014 in Intermediate, PHP

Enmanuel Corvo

Enmanuel Corvo

Software Engineer at LiveAnswer
Enmanuel Corvo is a Software Engineer experienced in Web Applications Development. Huge fan of Wordpress and an active plug-in author who enjoys writing code and blog posts about anything related to technology. Enmanuel also helps provide cloud solutions and software integrations to enterprise and small business.
Enmanuel Corvo

Latest posts by Enmanuel Corvo (see all)

As you might have noticed from many of my previous posts, I am a big fan of Twilio. The reason is because it is really easy to use, its very reliable, and it is also cheap. There are a ton of cool things you can do with Twilio, from Sending SMS to Receiving and Dialing calls. This simple tutorial will show you how easy it is to use Twilio to place outbound calls. Placing outbound calls using Twilio There are two ways you can dial calls with Twilio. One way is using their Rest API. The other way is using TwiML. With TwiML you don’t have to rely on the Rest API at all. You don’t need to include SDKs, you can do this in a few lines of code in a single file. The only catch to this is that you can only use this method (TwiML) with calls that are already in progress, you cannot initiate a new call leg with TwiML. As opposed to the Rest API, which allow you to initiate call legs. TwiML are meant to control the flow of a call that has already been initiated without having to make requests to the Rest API which could take long sometimes, affecting the overall efficiency of your application. Start dialing out Lets go ahead and create a directory where we will be placing the code to dial outbound calls “/twilio-voice-demo”. The next step is to include the Twilio SDK in this directory so we...

Creating a WordPress plugin for beginners

By on Jan 31, 2014 in Beginners, PHP

Enmanuel Corvo

Enmanuel Corvo

Software Engineer at LiveAnswer
Enmanuel Corvo is a Software Engineer experienced in Web Applications Development. Huge fan of Wordpress and an active plug-in author who enjoys writing code and blog posts about anything related to technology. Enmanuel also helps provide cloud solutions and software integrations to enterprise and small business.
Enmanuel Corvo

Latest posts by Enmanuel Corvo (see all)

WordPress has become the most popular CMS platform out there. It is very reliable and easy to use, but most of its success is due to the fact that WordPress is one of the most dynamic platforms, it can be extended via open source plugins that are available for free, and also paid one. Any body can develop a plugin for WordPress, and it does not take much to create a WordPress plugin. This concise tutorial is aim to guide you through the steps of creating a WordPress plugin from scratch. WordPress is PHP base which makes it easy to understand and grasp. PHP is such a popular language that almost any web developer is familiar with it in some way. This popular accessibility is key to WordPress success. Building a plugin is just a matter of understanding a file structure and begin able to follow well written documentation from the WordPress website itself. Thats yet another good thing about WordPress, it is packed with documentation like no other CMS. Getting Started Its possible to follow this simple tutorial by just reading through it; however, I recommend that you download and install WordPress in your localhost so you can follow the steps in creating the plugin. It should be fairly simple to get WordPress running in your local host. Just make sure you have a local server running in your machine, free version of MAMP has done the trick for me for quite some time now. But before I...