Client LoginView your Shopping CartHelp & Frequently Asked QuestionsEmail Us
Home Services Portfolio Web Design Pricing Dreamweaver Templates Web Applications Free Tutorials About Contact Us
Services > CSS Web Design | Professional Logo Design | ASP.net, ASP & PHP Programming | Flash Animation & Programming | Reliable Web Hosting | Website Maintenance
Portfolio > Web Design Portfolio | Web Programming Portfolio | Logo Design Portfolio | Web Design Pricing > Custom Web Design | Logo Design | Business Card Design
Free Web Design Guide > Website Design w/ Dreamweaver & Fireworks | Adobe Fireworks CS4 review | Photo Effects | Text Effects | Graphic Design Ideas | Web Design Ideas
Website Navigation Ideas | CSS Styles Tutorial | Dreamweaver Template | Server Side Includes | Flash Tutorials > Flash Effects | Flash Sound Button | Sound On/Off Button
Flash Preloader | Import External Data | Promotion > SEO Tips | Google Tips & Page Rank | JavaScript > Date Validation | Email Validation | Phone Validation | Tip Boxes

PHP General Tips

In this tutorial you will learn some general tips on PHP programming - debugging common errors in PHP, sending HTML formatted message in PHP, sending and receiving HTML mail messages.

1. Common Errors in PHP

'Warning: Cannot modify header information - headers already sent by (output started at filename line no __) '

If you run a PHP document get the above error message, it means that an error has occured in your php document. This takes place if there are any executable statements like echo before the set cookie or session variable. Try to find the statement and remove it and then run the same program.

2. Sending HTML message using PHP mail function

If you want to send HTML text message in the mailbody without any instruction in the mail function it can be done as follows using the PHP mail function.

Example:

$strFrom="baskar@smartwebby.com";

$strTo="mail@smartwebby.com";

$strSubject="Sending HTML text in php mail";

$strMailbody="mailbody<br>Welcome to <a href="www.smartwebby.com">smart webby</a><br><br><b>Best Regards</b><br><b>SmartWebby";

Mail function for HTML message format is as shown below:

Mail Function:

mail($strTo,$strSub,$strMailbody,"From:$strFrom/r/nReply-to:$strFrom);

When sending mail using the above format, you'll receive a mail in plain text as shown below.

From:baskar@smartwebby.com To:mail@smartwebby.com
Subject:Sending HTML text in php mail

mailbody<br><a href="www.smartwebby.com">Welcome to smart webby</a><br><br><b>Best Regards</b><br><b>SmartWebby

So we send the HTML text in the mailbody using the following statement

mail($strTo,$strSub,$strMailbody,"From:$strFrom\r\nReply-to: $strFrom\r\nContent-type: text/html; charset=us-ascii");

Ouput for the above format is as shown below:

From:baskar@smartwebby.com To:mail@smartwebby.com
Subject:Sending HTML text in php mail

mailbody
Welcome to smart webby

Best Regards,
SmartWebby

Absolutely FREE Web Templates
Check out these quality free web templates and download them without any registration or sign-up!

FREE Web Design Guide
From web design tips & ideas to HTML, CSS Styles, Fireworks & Dreamweaver you'll find all you need to know about effective web site design right here!

Quality Dreamweaver Templates
Professional quality dreamweaver templates in over 20 categories, starting at just $9.95! Instant download & easy customization

Beauty Templates | Business Templates | Christian Templates | CSS Templates | Education Templates | Family Templates | Flash Templates | Free Dreamweaver Templates
Food Templates | General Templates | Government Templates | Health/Medical Templates | Hi-Tech Templates | Kids/Childcare Templates | Low-cost Budget Templates
Personal Templates | Pets Templates | Photography Templates | Profession Templates | Real Estate Templates | Sports Templates | Telecom Templates | Travel Templates
Free Tutorials > Web Design Tutorials | CSS Web Design | Fireworks Tutorials | Dreamweaver Tutorials | Flash Tutorials | SEO Tutorials | Javascript Tutorials | PHP Tutorials