Categories

.NET (1) CSS (5) OOP (1) PHP (2) SQL (5) SQL Server (8) TSQL (1)

Friday, September 17, 2010

Sending HTML email through PHP

We can use mail function of PHP to send emails. For sending HTML email we've to set some headers.

Here is the syntax..


    $from="test@test.com";
    $to="test@test.com";
    $subject="your subject";



    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";    

    $headers .= "From: ".$from."\r\n";
    $headers .= "Reply-To: ".$from."\r\n";
    $headers .= "Return-Path: ".$from."\r\n";



   if (mail($to,$subject,$message,$headers) )
   {
   echo 'Successfully sent'; 

    } else {

       echo "Email address is not valid";

    } 

Wednesday, September 15, 2010

CSS HACKS

Cross browsing is the main issue for the web developer because each browser has its own standards. So sometimes there are some formatting issues in different browsers. There are several techniques to handle these issues. One of them is CSS hacks. You make different CSS files and then check the browser and then load the corresponding CSS.

Here is the syntax of CSS hacks..


<link href="all_browsers.css" rel="stylesheet" type="text/css"> 
<!--[if IE 7]> <link href="IE7.css" rel="stylesheet" type="text/css"> <![endif]-->
<!--[if IE 8]> <link href="IE8.css" rel="stylesheet" type="text/css"> <![endif]-->
<!--[if !IE]>--> <link href="style.css" rel="stylesheet" type="text/css"> <!--<![endif]-->


Now these if statements will check the browser and then load the corresponding CSS file.

Wednesday, September 8, 2010

Making a two-column webtemplate using HTML and CSS

Consider this structure

<div class="mainDiv">
        <div class="headerDiv">
            <h2>This is my header</h2>
        </div>
        <div class="navigationDiv">
            <ul>
                <li><a href="#">Link1</a></li>
                <li><a href="#">Link2</a></li>
                <li><a href="#">Link3</a></li>
                <li><a href="#">Link4</a></li>
                <li><a href="#">Link5</a></li>
             </ul>
        </div>
        <div class="mainBodyDiv">
            <div class="leftContentDiv">Left</div>
            <div class="rightContentDiv">Right</div>
        </div>
        <div class="footerDiv">Footer</div>     
      
    </div>
 

How to Centre a DIV Block Using CSS

Consider this structure.

<body>

<div id="wrapper">
</div>

</body>


CSS Property:

body {
    text-align: center;
    min-width: 600px;
    background:green;
}

#wrapper {
    margin:0 auto;
    width:600px;
    text-align: left;
    background:red;
    height:100px;
}




The technique will center the DIV because we are setting the margins to auto, web browsers are required by the CSS standard to give them equal width from both sides.

Reset HTML default properties in CSS

We can initialize all the HTML properties to value zero. Put this piece of code in  your CSS file.

* {
    vertical-align: baseline;
    font-weight: inherit;
    font-family: inherit;
    font-style: inherit;
    font-size: 100%;
    border: 0 none;
    outline: 0;
    padding: 0;
    margin: 0;
 }
body,html
{
    margin:0px;
    padding:0px;
    color:#000;
    background:#CCC;
    background-image:url(../images/background.jpg);
}