PHP 5 File Upload


First, ensure that PHP is configured to allow file uploads.
In your “php.ini” file, search for the file_uploads directive, and set it to On:
file_uploads = On

PHP CODE: (upload.php)
======================

$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
    $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if($check !== false) {
        echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        echo "File is not an image.";
        $uploadOk = 0;
    }
}
// Check if file already exists
if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    $uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
    echo "Sorry, your file is too large.";
    $uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
    echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}

How to send mail from PHP Localhost Server


Yes, we can send the Email from Local Machine and Internet Connection is must.
Open your php.ini file located in your folder C:\wamp\bin\php\php5.3.4
Search for mail function in the php.ini file. Change localhost to mailer server name of your webhosting account and save it. Finally restart your local wamp server.

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.yourdomain.com
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
sendmail_from = info@yourdomain.com

Pinterest-Style Column Layout In Pure CSS


<div id="wrapper">
    <div id="columns">
    
        <figure>
        <img src="demo.jpg" alt>
        <figcaption>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</figcaption>
        </figure> 

        <figure>
        <img src="demo_2.jpg" alt>
        <figcaption>caption goes here...</figcaption>
        </figure> 

        <figure>
        <img src="demo_3.jpg" alt>
        <figcaption>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</figcaption>
        </figure> 
..................
        
    </div>
</div>  

<------------ CSS ------------>  
#wrapper {
        max-width:80%;
        margin: 0 auto;
    }
    #columns {
        column-gap: 15px;
        column-width: 220px;
        -moz-column-gap: 15px;
        -moz-column-width: 220px;
        -webkit-column-gap: 15px;
        -webkit-column-width: 220px;
        background: rgba(0, 0, 0, 0);
        font-family: Arial,sans-serif;
        padding: 15px;
        width: 100%;
    }    

    div#columns figure {
        background: none repeat scroll 0 0 #fefefe;
        border: 2px solid #fcfcfc;
        box-shadow: 0 1px 2px rgba(34, 25, 25, 0.4);
        display: inline-block;
        margin: 0 2px 15px;
        padding: 15px 15px 10px;
        transition: all 0.4s ease-in-out 0s;
        text-align: center;
    }

    div#columns figure img {
        width: 100%; 
        height: auto;
        border-bottom: 1px solid #ccc;
        padding-bottom: 15px;
        margin-bottom: 5px;
    }
    #columns figure figcaption {
        color: #444;
        font-size: 0.9rem;
        line-height: 1.5;
        margin: 0;
        text-align: left;
    }

Equal height columns using only CSS


<div class="page-container"> 
    <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit.  
    Etiam congue, tortor in mattis mattis, arcu erat pharetra orci, at vestibulum lorem ante a felis.  
    Integer sit amet est ac elit vulputate lobortis. Vestibulum in ipsum nulla. Aenean erat elit,  
    lacinia sit amet adipiscing quis, aliquet at erat. Vivamus massa sem, cursus vel semper non,  
    dictum vitae mi. Donec sed bibendum ante. 
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.  
    Etiam congue, tortor in mattis mattis, arcu erat pharetra orci, at vestibulum lorem ante a felis.  
    Integer sit amet est ac elit vulputate lobortis. Vestibulum in ipsum nulla. Aenean erat elit,  
    lacinia sit amet adipiscing quis, aliquet at erat. Vivamus massa sem, cursus vel semper non,  
    dictum vitae mi. Donec sed bibendum ante.
    </div> 
   
    <div class="sidebar">Lorem ipsum dolor sit amet, consectetur adipiscing elit.  
    Etiam congue, tortor in mattis mattis, arcu erat pharetra orci, at vestibulum lorem ante a felis.
    </div> 
</div> 

.page-container { 
    display: table; 
} 
 
.content { 
    width: 450px;
    padding: 20px;
    float: none;
    display: table-cell;
    vertical-align: top;
    background-color: #CCC; 
} 
 
.sidebar {
    width: 250px;
    padding: 20px;
    float: none;
    display: table-cell;
    vertical-align: top;
    background-color: #999; 
} 

Shadow related CSS


BOX SHADOW:
————

.shadow {
	-moz-box-shadow: 3px 3px 4px #000;
	-webkit-box-shadow: 3px 3px 4px #000;
	box-shadow: 3px 3px 4px #000;
	/* For IE 8 */
	-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000')";
	/* For IE 5.5 - 7 */
	filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000');
}

BACKGROUND GRADIENT:
————

.background-gradient {
	background-color: #57839a;
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1,startColorstr=#57839a, endColorstr=#58859d);
background-image: -moz-linear-gradient(left, #57839a 0%, #58859d 50%,#5a88a0 100%);
background-image: linear-gradient(left, #57839a 0%, #58859d 50%,#5a88a0 100%);
background-image: -webkit-linear-gradient(left, #57839a 0%, #58859d 50%,#5a88a0 100%);
background-image: -o-linear-gradient(left, #57839a 0%, #58859d 50%,#5a88a0 100%);
background-image: -ms-linear-gradient(left, #57839a 0%, #58859d 50%,#5a88a0 100%);
background-image: -webkit-gradient(linear, left center, right center, color-stop(0%,#57839a), color-stop(50%,#58859d),color-stop(100%,#5a88a0));
}

Base Path for Link Tag


Base Path for Links:
It is not required to give a complete URL for every link. You can get rid of it if you will use
<base> tag in your header. This tag is used to give a base path for all the links. So your
browser will concatenate given relative path to this base path and will make a complete URL.
For example we have used following base tag in all the pages at domain.com:
<head>
</head>
So now if you will use
<a href=”/test/index.htm”>
then it will be considered as <a href=”http://www.domain.com//test/index.htm”&gt;