On Sale - Super Suite 44% off - Click here to learn more
 
  • Free Downloads
  • Free Dreamweaver Extensions
  • Free Dreamweaver Templates
  • Free PHP Scripts
  • Free Dreamweaver Tutorials and Training

Copy and paste Your free PHP Script

Developing websites can be a time consuming process. Therefore, any time you can save along the way beneficial. To help speed up your PHP web development we offer a collection of free PHP scripts which you will find below. If you like what you find check out our PHP solutions – there great when developing for clients.

Free PHP Code

Take a look at our free PHP code below and use any of it on as many sites as you desire.

301 Page Redirect

A free PHP script which quickly enables you to redirect your users to a new page in an SEO friendly way.

<?php
  header
("HTTP/1.1 301 Moved Permanently");
  
header("Location: [YourPageName]");
?>
Send an Email

This free PHP script allows users to send a quick email from your site.

<?php
  $Name 
"Da Duder"//senders name
  
$email "email@adress.com"//senders e-mail adress
  
$recipient "PersonWhoGetsIt@emailadress.com"//recipient
  
$mail_body "The text for the mail..."//mail body
  
$subject "Subject for reviever"//subject
  
$header "From: "$Name " <" $email ">\r\n"//optional headerfields
  
mail($recipient$subject$mail_body$header); //mail command :)
?>
Format Date

Here is a free PHP script that will enable you to easily reformat how date and time are presented on your site.

<?php
  
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
  // Mountain Standard Time (MST) Time Zone

  
$today date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
  
$today date("m.d.y"); // 03.10.01
  
$today date("j, n, Y"); // 10, 3, 2001
  
$today date("Ymd"); // 20010310
  
$today date("h-i-s, j-m-y, it is w Day"); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
  
$today date("\i\t \i\s \t\h\e jS \d\a\y."); // it is the 10th day.
  
$today date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001
  
$today date("H:m:s \m \i\s\ \m\o\n\t\h"); // 17:03:18 m is month
  
$today date("H:i:s"); // 17:16:18

  // to format a date from a recordset, you would add the recordset date as a second argument like

  
$today date("F j, Y, g:i a"strtotime($row_recordset["DateColumnName"]));
?>
Validate Credit Card Number

This is a free PHP script that will return true or false depending on whether or not a valid credit card number is passed to it.

<?php
  
function isCreditCard($st) {
  if (
$st == 0)
    return (
false);
  if (
strlen($st) > 19)
    return (
false);
  
$sum 0$mul 1$l strlen($st);
  for (
$i 0$i $l$i++) {
    
$digit substr($st$l-$i-11);
    
$tproduct $digit*$mul;
    if (
$tproduct >= 10)
      
$sum += ($tproduct 10) + 1;
    else
      
$sum += $tproduct;
    if (
$mul == 1)
      
$mul++;
    else
      
$mul--;
  }
  if ((
$sum 10) == 0)
    return (
true);
  else
    return (
false);
  }
?>
Clear Session

With this free PHP script you can either pass an array of session variable names to delete, or pass "true" to remove all session variables set. This is great for a logout page.

<?php
  
function clearSession($NamesArray) {
    if(
$NamesArray == true){
      foreach (
$_SESSION as $key => $value){
        unset(
$_SESSION[$key]);
      }
    }
    else{
      foreach(
$NamesArray as $value){
        unset(
$_SESSION[$value]);
      }
    }
  }
?>
Get Page as a String

Here is a great free PHP script for creating html templates and including their content in an email body.

<?php
  ob_start
();
  require_once(
dirname(__FILE__) . ("/Email_Templates/receipt.php"));
  
$contents ob_get_clean();
?>