Websites

This section of my portfolio showcases the latest websites I have worked on and a description of the work performed on that site. This does not include every website that I have built and/or worked on previously. Reasons for this may be that the website is currently non-existant, the amount of work done on the site was not meaningful enough to describe, or I have simply failed to include them in my portfolio. If you would like to see more websites I have worked on, you can view all of my websites here

Small Engine Doc (in progress)

This is a website I am currently working on for a customer that includes a full content management system, blog system, article and product review system, and various other features. This was created using Photoshop, xhtml, css, javascript, ajax, php, and mysql. View website

Artist Hands at Work (in progress)

This is a website that I am currently finishing up for a customer. This website features a full content management system and portfolio with sub-portfolios for seperate jobs. This website is currently awaiting content for completion. This website was created using Photoshop, xhtml, css, php, and mysql. View website

ECPI Design Awards

This is a website I worked on in early 2008 for the ECPI design awards. My work on this site included the development of user registration, login, and mangement system, gallery system, voting system, statistics logging, and an extensive administration system with various security measures in order to protect the quality of the design contests. The control panel includes features such as submission validation processing, user management, contest management, archive control, messaging system, and various other features. The back-end development of this site took approximately a month to complete from start to finish. My work on this website was completed using xhtml, css, javascript, ajax, php, and mysql. View website

Eagle Landscaping

This is a website I did for a small landscaping company. I designed and developed this site in late 2007. This is a simple website which features a flash header, photo gallery, and content management system to the customer's specifications. This website was created using Photoshop, Flash, xhtml, css, php, and mysql. View website

Code Samples

This section of my portfolio showcases a few code samples I have provided in order to give you a better understanding of my work. If you would like to see more code samples, you can view all of my code samples here

AJAX-like Uploader Example - PHP

<?php
require_once('db.php');
require_once('functions.admin.php');

$folder = '../portfolio/';

if ($_FILES['file']) {
	if ($_FILES['file']['error'] == 0) {
	
		echo $folder.'<br />';
		
		echo $_FILES['file']['name'].'<br />';

		$newFile = $folder."/".$_FILES['file']['name'];
		$dbFile = 'portfolio/'.$_FILES['file']['name'];
		
		echo $newFile.'<br />';
		
		if (move_uploaded_file($_FILES['file']['tmp_name'], $newFile)) {
			switch($_POST['type']) {
				case 'thumb':
					addThumb($dbFile, maxID('site'));
					break;
				case 'image':
					addImage($dbFile, maxID('site'));
					break;
			}
			?>
			<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
			<html xmlns="http://www.w3.org/1999/xhtml">
			<head>
			<script type="text/javascript" src="../js/uploader.js"></script>
			<body onLoad="doneloading(parent, '<?=$newFile?>', '<?=$_POST['statusId'];?>', '<?=$_POST['uploadId'];?>', '<?=$_POST['submitId'];?>')">
				<img src="<?=$newFile?>" />
			</body>
			</head>
			</html>
			<?php
		
		} else echo 'There was an error uploading the file.';
	}
}

?>

This is an example showing how the AJAX file uploader is processed on the back-end after posting.


AJAX-like Uploader - JavaScript

function uploadFile(form, statusId, uploadId, submitId) {
	document.getElementById(submitId).style.display = 'none';
	document.getElementById(uploadId).style.display = 'inline';
	document.getElementById(statusId).innerHTML = 'Uploading...';
}

function doneloading(frame, file, statusId, uploadId, submitId) {
	frame.document.getElementById(submitId).style.display = 'inline';
	frame.document.getElementById(uploadId).style.display = 'none';
	frame.document.getElementById(statusId).innerHTML = 'Upload Complete!';
}

This is the small JavaScript file required to make the php uploader class function as it should.


AJAX-like Uploader Class - PHP

<?php
class uploader {
	
	var $formName;
	var $frameName;
	var $fileID;
	var $frameID;
	var $statusID;
	var $uploadID;
	var $submitID;
	var $type;
	
	function __construct($action, $type='default', $title='Upload:') {
		$r = rand(111,999);
		$this->formName		= 'formUpload'.$r;
		$this->frameName	= 'frameUpload'.$r;
		$this->fileID		= 'file'.$r;
		$this->frameID		= 'frame'.$r;
		$this->statusID		= 'uploadStatus'.$r;
		$this->uploadID		= 'loadingAnimation'.$r;
		$this->submitID		= 'submitFile'.$r;
		$this->type			= $type;
		$this->showForm($action, $title);
	}
	
	function showForm($action, $title) {
		echo '<form name="'.$this->formName.'" action="'.$action.'" method="post" enctype="multipart/form-data" target="'.$this->frameName.'" onsubmit="uploadFile(document.'.$this->formName.', \''.$this->statusID.'\', \''.$this->uploadID.'\', \''.$this->submitID.'\');">
				'.$title.'<br />
				<input type="hidden" name="type" value="'.$this->type.'" />
				<input type="hidden" name="statusId" value="'.$this->statusID.'" />
				<input type="hidden" name="uploadId" value="'.$this->uploadID.'" />
				<input type="hidden" name="submitId" value="'.$this->submitID.'" />
				<input type="file" id="'.$this->fileID.'" name="file" />
				<input id="'.$this->submitID.'" type="submit" name="submit" value="Upload" style="display: inline;" />
				<img id="'.$this->uploadID.'" src="../images/loader.gif" style="position: relative; top: 5px; display: none;" />
				<p id="'.$this->statusID.'" style="margin: 0; padding: 0;">&nbsp;</p>
				<iframe id="'.$this->frameID.'" name="'.$this->frameName.'" src="'.$action.'" style="display: none;"></iframe>
			</form>';
	}

}
?>

Since it is actually not possible to process file uploads using AJAX and the XMLHttpRequest, file uploads can simulate AJAX functionality with the use of iframes and javascript. This is file upload class which creates a unique file upload form. There is a corresponding JavaScript file and example usage file.


Simple contact form - PHP

<?php

if ($_POST) {
	session_start();
	if ($_SESSION['contact'] >= 2)
		$error[] = 'You cannot send more than two messages. Please wait for a response.';
	else {
		if (!$_POST['name'] || $_POST['name'] == '')		$error[] = 'You must include your name.';
		if (!$_POST['email'] || $_POST['email'] == '')		$error[] = 'You must include your email address.';
		if (!$_POST['subject'] || $_POST['subject'] == '')	$error[] = 'You must include a subject.';
		if (!$_POST['message'] || $_POST['message'] == '')	$error[] = 'You must include a message.';
		if (!$error) {
			$headers =	'From: ' . $_POST['email'] . "\r\n" .
						'Name: '.$_POST['name'] .
						'Reply-To: '.$_POST['email']."\r\n" .
						'X-Mailer: PHP/' . phpversion();
			if (!mail('bmt27870@gmail.com', $_POST['subject'], $_POST['message'], $headers))
				$error[] = 'There was an error sending your message.';
			if (!$error) $_SESSION['contact']++;
		}
	}
}

?>
<h4>Contact Me</h4>
<div id="contact">
	<?php
		if ($error) {
			echo '<p class="error">
				  The following errors occurred:<br /><br />';
			foreach ($error as $e)
				echo $e.'<br />';
			echo '</p>';
		}
	?>
	<form name="contact" action="<?=$_SERVER['PHP_SELF'];?>" method="post">
		<label for="name">Name:</label><br />
		<input type="text" name="name" /><br />
		<label for="email">Email:</label><br />
		<input type="text" name="email" /><br />
		<label for="subject">Subject:</label><br />
		<input type="text" name="subject" /><br />
		<label for="message">Message:</label><br />
		<textarea name="message" rows="6" cols="40"></textarea><br />
		<input type="submit" value="Send" />
	</form>
</div>

This is a simple php contact form I created in php. It doesnt include any validation beyond simply checking if the fields are blank or not. I usually do form validation in javascript using regular expressions.


My porfolio functions - functions.portfolio.php

<?php
require_once('db.php');

function fetchSites($showall=NULL) {
	global $mysqli;
	if ($showall)
		$query = "SELECT * FROM portfolio_sites ORDER BY id DESC";
	else
		$query = "SELECT * FROM portfolio_sites ORDER BY id DESC LIMIT 5";
	if ($result = $mysqli->query($query)) {
		while ($row = $result->fetch_assoc()) {
			$html .= '<div class="site"><p class="title"><a href="'.$row['link'].'" title="'.$row['title'].'">'.$row['title'].'</a></p>
				  	  <a href="'.$row['img'].'" title="'.$row['title'].'" rel="lightbox[portfolio]"
					  onmousedown="this.title=\'<a href=\\\''.$row['link'].'\\\' target=\\\'_blank\\\'>'.$row['title'].'</a>\';">
					  <img class="thumb" src="'.$row['thumb'].'" /></a>
					  <p class="description">'.$row['description'].'
					  <a href="'.$row['link'].'" title="'.$row['title'].'" target="_blank">View website</a></p>
					  <div class="clear"></div></div>';
		}
	}
	return $html;
}

function fetchCode($showall=NULL) {
	global $mysqli;
	if ($showall)
		$query = "SELECT * FROM portfolio_code ORDER BY id DESC";
	else
		$query = "SELECT * FROM portfolio_code ORDER BY id DESC LIMIT 5";
	if ($result = $mysqli->query($query)) {
		while ($row = $result->fetch_assoc()) {
			$html .= '<div class="code"><p class="title">'.$row['title'].'</p>
				  <pre name="code" class="'.$row['type'].':nogutter:collapse">'.$row['code'].'</pre>
				  <p class="comments">'.$row['comments'].'</p></div><hr />';
		}
	}
	return $html;
}

function fetchCodeTypes() {
	global $mysqli;
	$query = "SELECT * FROM code_types";
	$html = '<div id="codeTypes"><ul>
			 <li><a href="portfolio.php?show=code" title="All">All</a></li>';
	if ($result = $mysqli->query($query)) {
		while ($row = $result->fetch_assoc()) {
			$html .= '<li><a href="portfolio.php?code='.$row['type'].'" title="'.$row['title'].'">'.$row['title'].'</a></li>';
		}
	}
	$html .= '</ul></div>';
	return $html;
}

function fetchCodeType($type) {
	global $mysqli;
	$query = "SELECT * FROM portfolio_code WHERE type='$type'";
	if ($result = $mysqli->query($query)) {
		while ($row = $result->fetch_assoc()) {
			$html .= '<div class="code"><p class="title">'.$row['title'].'</p>
				  <pre name="code" class="'.$row['type'].':nogutter:collapse">'.$row['code'].'</pre>
				  <p class="comments">'.$row['comments'].'</p></div><hr />';
		}
	}
	return $html;
}

?>

This is the code used in my portfolio which you are viewing right now. I have included this code to give a general idea of my programming style.