Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

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