1st option:
<?
$content_len=@filesize("file.zip");
Header("Content-type: application/zip");
Header("Content-type: octet-stream");
Header('Content-Disposition: attachment; filename="file.zip"');
if($content_len!=FALSE)
{
Header("Content-length: $content_len");
}
readfile("file.zip");
?>
2nd option:
<?
$files="servicesellersmasterscourse.zip";
$filenames="servicesellersmasterscourse.zip";
$url= "/www/download/";
$total=$url . $files;
Header ( "Content-Type: application/octet-stream");
Header ( "Content-Length: ".filesize($total));
Header( "Content-Disposition: attachment; filename=$filenames");
readfile($total);
?>
Monday, October 20, 2008
Saturday, October 18, 2008
Add form to website
Form is one of the basic elements to make a website interactive. It is used to received information from user. The information could be comment, contact details, query, order form etc.
A simplest form application will have atleast 2 parts – the form and the form processing script.
Form is developed in HTML. If you like someone’s form or the form element then you can simply view source of the page and can copy and the form or the form element and paste it in your page. Some complex forms are developed using server side scripting language. But the output is sent to client in HTML format.
Form data is sent to server as visitor clicks the submit button. On server we have a form processing page which processes the data. The path and name of the processing page is specified in the action tag of form. We can do any processing on the data like saving it to database or simply mailed to you on your email account.
The simple and very common use of form is on “contact us” page. I had already posted script to process contact us page. You can find it at: http://techutility.blogspot.com/2008/10/php-code-to-mail-form-content.html. This script will mail all the visitor’s filled information to you. Just create a file named process.php and paste the code into it. Edit the code and add your email ID. On form put process.php in the action field.
Use small forms on your website to get visitor’s comment. Don’t forget ever to reply to their queries.
If you face any problem in implementing form then contact me.
A simplest form application will have atleast 2 parts – the form and the form processing script.
Form is developed in HTML. If you like someone’s form or the form element then you can simply view source of the page and can copy and the form or the form element and paste it in your page. Some complex forms are developed using server side scripting language. But the output is sent to client in HTML format.
Form data is sent to server as visitor clicks the submit button. On server we have a form processing page which processes the data. The path and name of the processing page is specified in the action tag of form. We can do any processing on the data like saving it to database or simply mailed to you on your email account.
The simple and very common use of form is on “contact us” page. I had already posted script to process contact us page. You can find it at: http://techutility.blogspot.com/2008/10/php-code-to-mail-form-content.html. This script will mail all the visitor’s filled information to you. Just create a file named process.php and paste the code into it. Edit the code and add your email ID. On form put process.php in the action field.
Use small forms on your website to get visitor’s comment. Don’t forget ever to reply to their queries.
If you face any problem in implementing form then contact me.
Thursday, October 16, 2008
PHP form processing script
The script sends all the data filled in the form on your website to your specified email id. The good thing about the script is that you didn't have to check the field names and add individually. The script takes all the variable and send to you with the field name you had put in the form. So, it is good to put meaningful field names.
<?php
$body = "*************************************************************************\n";
foreach($_POST as $i => $value){
if($i != 'B1_x' && $i != 'B1_y'){
$body .= "$i: ".stripslashes($value)."\n";
}
}
$body.="\n";
$body.="\nUSER AGENT: ".$_SERVER['HTTP_USER_AGENT'];
$body.="\nDATE: ".date("l dS of F Y h:i:s A");
$body.="\nComment for ".$_SERVER['HTTP_REFERER'];
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: excelsolutions.biz <> \n";
$headers .= "Reply-To: valid_id@yourdomain.com";
if(!$form_name) $form_name = "Page Feedback";
// $to = "valid_id@yourdomainname.com";
$to = "valid_id@yourdomainname.com";
$subject = $form_name;
mail($to, $subject, $body, $headers)
?>
Subscribe to:
Posts (Atom)