Friday, July 30, 2010

Promote Facebook Page with Like Box Plugin

This post is actually a continuation on my post about creating a facebook official page. This time, we will create a code to embed in our website to promote the page we had just created. If you don't have a facebook official page yet, you can visit the post about Facebook Official Page for Website.

1. Go to facebook home page or you can click facebook home page. Log in to your account and on the left side below your profile image try to locate "Ads and Pages" and click on it.



If you can not find the "Ads and Pages" link, you can look for your page by typing the page name in the search bar. You will be redirected to your page after clicking on it.


Now, click on "Edit Page" below the image of your page on the left.


 2. On the right part of the page, click on "Promote with a Like Box" under Promote your Page section.


3. You are now on the Social plugins creator for Like Box. There is a default like box on the preview, you can change it by changing Facebook Page ID field by profile_id in the url and the preview will automatically change to your page. You can customize it by changing the remaining fields.


4. After you decided your Like Box would look like, you can now click on the "Get Code" button.



5. You can now see your Like Box plugin code. You can select between iframe or XFBML which you would like to embed to your website.


6. You can now copy the code and paste it on the page you wanted for your website. You can see my facebook official page like box at the right side of my website.

Thursday, July 29, 2010

Facebook Official Page for Website

Inside the world wide web, who does not know about Facebook? I think almost everyone has account on this famous social networking site to connect with your friends all over the world. Today, this is not only used as medium of communication but also useful in promoting a business, celebrity, band, product or even organization.


Now, I will teach you how to create your own fan page on facebook. The steps are very easy but I believe it would be much easier if there are thumbnails on the steps.

1. Go to facebook home page. At the bottom of page below the sign up form, you can see the link Create a Page then click on it.




2. You are now on the create page area where in you can see the form. Select between the three radio buttons depending on the page you want to promote. A drop down selection will appear for you to select specifically your interest.



3. Enter the name of your page on the "Page Name" field and check the box before the statement "I'm the official representative of this person..." and then click on the "Create Official Page" button.




4. If you are currently log in to your facebook account, you will skip this step. If not, you have to log in if you already have an existing account otherwise you have to select the statement "I do not have a Facebook account" and create a new one of course for free.



5. Now, you have  successfully created your own official facebook page. You can customize your page as long as you want like :

     - Browse and upload an image or take a picture from your computer if you have the camera.



     - Provide your basic information about you and your page.



     - Post status updates for your page.



     - Promote your page on your website.



     - Set up your mobile phone for your page.



     - Connect with your twitter account to send status to your followers.

Wednesday, July 28, 2010

Add Paypal Donation Button to Website

Do you want to have a paypal donation button for your web page where in your avid visitors of your website will donate some money for your effort? You can follow the simple steps:

1. Log in to your Paypal account. If you don't have a paypal account, you can visit paypal page and get a Free Paypal account by clicking sign up.


2. After the successfull log in, click on the "Merchant Services" tab.


3. Scroll down your browser window and  in the right part of the page under Key Features, click "Donations".


4. You will see some options where "Donations" is the selected, just leave it this way. Fill out the first field (Organization name/service) which is required and all the remaining fields are optional. You can customize your button and preview it. You can now click "Create Button".


5. Now, you will see the page containing the html code for your paypal donation. Copy the code and place it to your web page and your done.


You now have a donation button for your website.

Tuesday, July 27, 2010

Force Download File Using PHP Header Function

Do you want to have a web page that has a script that can make a force download.


I have an example here using PHP to push the file to the browser. To trigger the download of the file, we will use HTML header statements. In PHP, this is possible using header function in passing raw HTML headers to the browser. In this example we will pass the filename in the url for instance - www.domainname.com/download.php?file=filename.zip. Of course, you can customize the codes according to the functionality of your website.


<?php

//path directory of the file
$dir="downloads/";
//cehck if there is a file passed
if (isset($_REQUEST["file"])) {
    //concatinate the directory and the filename
    $file=$dir.$_REQUEST["file"];
    //set HTML headers that must be sent to the browser.
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    //read the file
    readfile($file);
    exit;
}
else {
    //prompt if no file selected
    echo "No file selected";
}

?>


Click here for the php header manual

Monday, July 26, 2010

WampServer - Install PHP Apache MySQL on Windows

If you are a web developer and want to install php, apache and mysql on Microsoft Windows operating system then I highly recommend you to use Wampserver. WampServer 2 is the new version of WAMP5. You just have to download the latest stable version at Wampserver Download Page. Just Click "DOWNLOAD WampServer" and the download window will appear shortly and then hit "Save File".


After the download is completed, locate the executable file and double click it to start the installation process. Just follow the usual installation steps on windows because everything is automatic. When the installation is finished, run the wampserver executable file. Just click the Wampserver trayicon to manage your server and its settings.


A "www" directory is created (generally c:\wamp\www) when you installed WampServer. Create a directory inside "www" for your project and where you should place your PHP files.
To view all your projects on the browser, click on the link "Localhost" in the WampServer menu or open the http://localhost address.



Now, you are ready to create your projects with php running in apache with mysql for the database.

Friday, July 23, 2010

Create Zip Archive File using PHP ZipArchive

Do you want to place certain files on a zip archive file? In php this is possible using the ZipArchive class - a file archive, compressed with Zip. Below is the sample code program of this functionality.


<?php

//sample files in an array to be compressed
$files = array(
    'images/img1.png',
    'images/img2.png',
    'images/img3.png',
    'images/img4.png',
    'images/img5.png'
);

//returns true if creation succeed and false if zip creation failed
$result = create_zip($files,'my-archive.zip');

//function that creates a compressed zip file
function create_zip($files = array(),$destination = '',$overwrite = false) {
    //if the zip file already exists and overwrite is false, return false
    if(file_exists($destination) && !$overwrite) { return false; }
    //variable declaration
    $valid_files = array();
    //if files are valid
    if(is_array($files)) {
        //loops and check each file
        foreach($files as $file) {
            //check if file exists and store in array
            if(file_exists($file)) {
                $valid_files[] = $file;
            }
        }
    }
    //check if there are valid files
    if(count($valid_files)) {
       //create the zip archive object
       $zip = new ZipArchive();
       if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE :     ZIPARCHIVE::CREATE) !== true) {
           return false;
       }
        //add files to the object
        foreach($valid_files as $file) {
          $zip->addFile($file,$file);
        }

       //close the zip after adding the files
        $zip->close();

        //check if the destination file exists
        return file_exists($destination);
    }
    else {
        return false;
    }
}

?>