how to download a file without display download request
Usually when we try to download something from a server we get a confirmation request whether you want to save the file or open it.
To avoid this request you can use the below code and then user can directly download that file without any message.
First give a link or a button for user to download and when they click redirect them to a file which will have the code below.
suppose you want user to download a pdf file then first make a link like this:
<a href=”javascript:void();” onClick=”location.href=’doc/document_download.php’”>download pdf</a>
Tags: attachment, Content type, Content-Disposition, direct download, download, file, filename, pdf download, Php
How to run code of php5 on a server with php4 using htaccess
Nov 26, 2009 Beginners, Experts, Php
This is big question for beginners every time.Now as we know that php5 is in full flow but still there are lot of servers out there with php4 and if you upload your php5 code on those servers then it will be mess.May be your site will not run or any part or your will go down.But don’t worry friends , there are only 2 lines to put this problem far from you.
Just put these 2 lines below in a htaccess file and put that htaccess at the root directory.
AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4
Now all the modules either they have written in php4 or php5 will work very well.
Php mail function
The mail() function allows you to send emails directly from a script. This function returns TRUE if the email was successfully accepted for delivery, otherwise it returns FALSE.
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
To send email using PHP, you use the mail() function. This accepts 5 parameters as follows (the last 2 are optional)
Tags: delivery, from, headers, html mail, mail function, mail(), message, parameters, Php, php mail, send mail, subject, text mail, to
Sessions in php
I always try to provide good information to beginners in php because these small looking problems may be big problem for a beginner. Session are one of them.
We use sessions when we get to a stage where our website need to pass along user data from one page to another.
A normal HTML website will not pass data from one page to another. In other words, all information is forgotten when a new page is loaded. This makes it quite a problem for tasks like a shopping cart, which requires data(the user’s selected product) to be remembered from one page to the next.
Using session you can send information between one page to another.However, this session information is temporary and is usually deleted very quickly after the user has left the website that uses sessions. Sessions work by creating a unique identification(UID) number for each visitor and storing variables based on this ID. This helps to prevent two users’ data from getting confused with one another when visiting the same web page. Read the rest of this entry »
Tags: array, Destroy session, isset, Multidimensional Arrays, passing value, Php, PHP session, print_r, session, session array, session_destroy, session_start, unset
Arrays in php
Arrays are always a big and typical topic for php beginners.Some times they left their job because of arrays.I was also one of them .But after a long experience now i understand that arrays are too easy in php like eating food because php has allready provided readymade funda for arrays .You just have to use that logic and nothing else.
An array in PHP is a collection of values. Like A map that associates values to keys. In an array each values associate to an Unique key and you can access valuse by using that key. As array values can be other arrays, trees and multidimensional arrays are also possible.
Tags: array, array_pop, array_push, dimensions, in_array, is_array, javascript array, key, ksort, Multidimensional, Php, rsort, sort, Three-dimensional Arrays, Two-dimensional Arrays, value