Course Recommendations

October 24, 2008 – 2:02 pm
  1. www.ineasysteps.com - books on CSS, XHTML and javascript
  2. HTML for the World Wide Web with XHTML and CSS: Visual QuickStart Guide, 5th Edition by Elizabeth Castro
  3. css menus - http://css.maxdesign.com.au/listamatic/
  4. website reference - www.sitepoint.com
  5. Lytebox scripts: http://www.dolem.com/lytebox/
  6. calendar scripts calendar.swazz.org/
  7. John Rowley AT VODAPHONE DOT IE (SPELL VODA CORRECTLY)
  8. 0872457746

For robert

July 29, 2008 – 7:06 pm

include_once("dbconnect.inc.php");
include_once("functions.inc.php");
echo "

I am the records file

“;

//SELECT ALL FIELDS FROM TABLE

#$sqlQuery = “SELECT * FROM robert1_dwarves where 1″;
#$sqlQuery = “SELECT *FROM robert1_dwarves where zid=3″;
$sqlQuery = “SELECT zid, name, concat(sha1(name),\”.doc\”) as uid, colour FROM robert1_dwarves where 1″;

echo “

Query is:
$sqlQuery

“;

//Assign result of the query to a variable
//this just indicates if it was valid or not
$result = mysql_query($sqlQuery);

if (!$result) {

}

$numRows = mysql_num_rows($result);

echo “

Number of records returned is: $numRows

“;

output_table_header();

while ( $record = mysql_fetch_assoc($result) ) {

output_row_start();
output_cell($record[’zid’]);
output_cell($record[’name’]);
output_cell($record[’colour’]);
output_cell($record[’uid’]);
output_row_end();
}

output_table_footer();
?>

DB Connection Code

July 29, 2008 – 6:41 pm

$link_id=@mysql_connect(DB_CLIENT_SERVER,DB_CLIENT_USER,DB_CLIENT_PASSWORD);

if($link_id) {
 echo “<p>Successful Connection</p>”;
}
 else {
 echo “<p>Unsuccessful Connection!</p>”;
}
if ( mysql_select_db(DB_CLIENT_DATABASE,$link_id) ) {
 echo “<p>Successful Database Selection</p>”;

} else {
die( “<p>Successful Database Selection</p>” );

}

Database Connection Code

July 8, 2008 – 5:46 pm

//Image size is 291 * 191
error_reporting(E_ALL);
define(”DB_CLIENT_HOST”,”testsite.efiberart.com”);
define(”DB_CLIENT_SERVER”,”sql2.hosting365.ie”);
define(”DB_CLIENT_DATABASE”,”bleahy_AppDB”);
define(”DB_CLIENT_USER”,”bleahy_aleahy”);
define(”DB_CLIENT_PASSWORD”,”leahyb02″);
define(”TABLE_GALLERY”,”master_gallery”);
define(”SERVER_PATH”, “/hsphere/local/home/bleahy/testsite.efiberart.com”);
//echo $_SERVER[’PATH’];
//echo “<P>” . $_SERVER[’PATH_TRANSLATED’];

//echo “<p>” . $_SERVER[’HTTP_HOST’];

function getPages() {

return array(”main”,”conversations”,”");

}

if ($_SERVER[’HTTP_HOST’]==DB_CLIENT_HOST) {

$link_id=@mysql_connect(DB_CLIENT_SERVER,DB_CLIENT_USER,DB_CLIENT_PASSWORD);

if($link_id) {
//echo “Successful Connection”;
}

if(mysql_select_db(DB_CLIENT_DATABASE,$link_id)) {
//echo “<p>Connection to art site success”;
} else {

//echo “<p>Connection to art db not a success”;
}

}

Web 2 - Final Day (carts, logins, sessions, config files0

June 4, 2008 – 3:41 pm

header(’Content-type: application/pdf’);
readfile(’demo.pdf’);
//
config.inc.php
        define(”DEBUG_ON”, 1);
 define(”DB_HOST”,
 define(”DB_PASSWORD”,
 define(”DB_USER”,
 define(”TABLE_USER”,
 define(”FIELD_USER”,
 define(”FIELD_PASSWORD”,
 define(”FORM_LOGIN”,’formLogin’)
 

dbconnect.inc.php

login.php
 include_once(”config.inc.php”)
 include_once(”dbconnect.inc.php”)
 include_once(”foos.inc.php”)
 session_start()
 
 $formName= generateFormname(FORM_LOGIN);
 
 if ( !isset($_POST[’formID’]) ||
      !isset($_POST[’fieldName’]) ||
      !isset($_POST[’fieldPassword’]) ||
     strlen(trim($_POST[’fieldName’]))==0 ||
     strlen(trim($_POST[’fieldPassword’]))==0 ||
     $_POST[’formID’] != $formName
    
    
    
     ) {
  echo display_login_form();
  exit;
 } else {
 
 $cleanName=htmlspecialchars($_POST[’fieldName’])
 $cleanPasword=htmlspecialchars($_POST[’fieldPassword’])
 
 
 
   if (   !boolValidateLogin($cleanName, $cleanPassword) ) {
     $_SESSION=array(); //clear any session variables
     session_destroy();
    echo display_login_form();
  
  
   } else {
  
  
    //echo “Logging in….”;
    $_SESSION[’loggedIn’]=1;
    header(”location: index.php”);
  
  
   } // else
 
 
 
 } // else valid fields posted
 
 
 
 
  fieldName
  fieldPassword
  login.php
  post
 
 
 
 
 
index.php
 session_start()
 define(”INDEX_PAGEx”,1);
 
 if(!isset($_SESSION[’loggedIn’]) {
 
 header(”location: login.php”);
 
 }
 
 echo “This is index.php”;
 echo “<a href=’logout.php’>Logout</a>”;
 
 
 
foos.inc.php
if(!defined(
INDEX_PAGE)) exit;
 function display_login_form() {
 
 $formName= generateFormname(FORM_LOGIN);
 
 
 <input type=’hidden’ name=’formID’ value=’$formName’ />
 
 
 }
 
 
 
 function generateFormname($formName) {
 
 
 
 
  return sha1($formName . date(”mdy”));
  
  
  
 
 
 }
 
 
 function trace($message) {
 
  if( DEBUG_ON) {
   echo “<p>$message</p>”;
  }
 
 }
 
 
 function boolValidateLogin($userName, $userPassword) {
 
 
 
 $sqlQuery = “SELECT * from ” . TABLE_USER .
            ” WHERE ” .
            FIELD_NAME .
            “=’$userName’ AND ” .
            FIELD_PASSWORD .
            “=’$userPassword’”;
 trace($sqlQuery);
 
 if (! $result = mysql_query($sqlQuery) ) {
 
  die(”Unable to execute query ” . mysql_error());
 
 } else {
 
  if (mysql_num_rows($result) == 1 {
  
  return 1;
  
  } else {
  
  return 0;
  
  }
 
 }
 
 exit;
 
 
 return 0;
 
 }
 
logout.php
 session_start();
 $_SESSION=array(); //clear any session variables
 session_destroy();
 header(”location: index.php”);
protected.php
 if (!defined(INDEX_PAGE))
  header(”location: index.php”);
  
  
  
  
cart
 Item 1 <a href=’addtocart.php?id=1′>Add to Cart</a>
 
 
 function countCartItems() {
 
 
 return sizeof($_SESSION[’cart’]);
 
 }
 
 
 echo “<p>Items in Cart: ” . countCartItems() . “</p>”;
 
 
 
 function initCart() {
 
 if (!isset($_SESSION[’cart’]))
  $_SESSION[’cart’]=array();
 
 
 
 }
 
 
 initCart();
 
 function add2Cart($id) {
 
 $_SESSION[’cart’][]=$id;
 
 
 
 
 }
 
 add2Cart($_GET[’id’]);
 header(”location: catalog.php”);
 
 
 function showCart() {
 
 $count = countCartItems();
 
 for($i=0; $i < $count; $i++) {
 
 echo “<p>” . $_SESSION[’cart’][$i] . “</p>”;
 
 
 }
 
 
 
 
 }
 
 
 
 
 function writeImage($filename) {
 
 
 
 echo “<img src=’../images/$filename’ />
 
 
 
 
 }

tcu

June 4, 2008 – 1:51 pm
index.cfm/page/boardpack?rdFolder=&rdDF=boardapr08.pdf

Javascript Operators

May 28, 2008 – 12:06 pm

http://www.webmasterworld.com/forum91/513.htm

Ternary Operator

May 28, 2008 – 11:59 am


var b=5;
(b == 5) ? a=”true” : a=”false”;
document.write(” ————————— “+a);

CSS - Free Chapter on CSS Layouts

May 28, 2008 – 11:11 am

http://www.friendsofed.com/samples/1590596145.pdf

CSS - Menus - Listamatic

May 28, 2008 – 10:59 am

http://css.maxdesign.com.au/listamatic/

Arrays - O’Reilly Article

May 28, 2008 – 10:49 am

http://www.oreilly.com/catalog/progphp/chapter/ch05.html

Exercise - PHP - Event Manager

May 13, 2008 – 12:03 pm

Create a form that contains a date select box, a performance times select box, a header description and a body description.

The date select box should be formatted in the form “Monday May 13th 2008″. It should show the next 30 days from the current date.

The  PerformanceTimes select box should show three performance times: 15:00, 20:00 and 21:00.

The Performance Times should be stored as an array and a foreach loop used to display.

The Header is a text input field and should allow for 50 characters. It will handle main title of the performance such as ” Joe Bloggs and his Merry Band”

The Body content is a longer description of the event.

The form is in a page called createevent.php

The form is processed by a page called processevent.php

The form is POSTED

No javascript validation is required

Subversion Commands

May 2, 2008 – 8:00 pm

svn checkout file:///c:/repositories/testrepos/testing

svnadmin create c:/repositories/testing

svn import c:\testfolder file:///c:/repositories/testrepos/testing

svn status -v
Lists changes in the system

Mysql - Updating a field example

April 23, 2008 – 3:57 pm

update DB_TABLE set field1=’x', field2=’y’ WHERE zid=’???????’;

update DB_TABLE set field2=’y’ WHERE date=’2008-04-28′;

update DB_TABLE set field1=’x’ WHERE name=’John’;

Class Exercise 23-04-08

April 23, 2008 – 3:50 pm
  1. Read up date functions and create ten different examples demonstrating how the date function works
  2. Read up on string functions and create ten different examples demonstrating how the various functions work - illustrating string length, replacing within strings, removing space from the start and end of strings, getting the first 5 letters of a string, locating the position of a character in a string, taking a string of the form “‘Name Surname” and extracting the surname from the string regardless what length the string is
  3. Read up on Javascript arrays and event handlers
  4. Create a table called mydates with zid and a mydate field which is datetime. Using code from today, create a form that creates records with different dates

Javascript Form Validation

April 23, 2008 – 11:52 am

http://www.tizag.com/javascriptT/javascriptform.php

Linux Commands

April 23, 2008 – 10:48 am

http://www.reallylinux.com/docs/direct.html

rm -r ??0208 // removes all directories and sub directories etc.

PHP Login / AuthenticationFunction

April 23, 2008 – 8:43 am

$cleanName = htmlspecialchars($_POST[’fieldName’]);
$cleanPassword = htmlspecialchars($_POST[’fieldPassword’]);

validateuser($cleanName, $cleanPassword);

function validateUser($fieldName, $fieldPassword) {

$sqlQuery = “SELECT * from TABLE_USERS WHERE username = $fieldName AND upassword = $fieldPassword”;

$result = mysql_query();

if(!$result) die(mysql_error());

if ( mysql_num_rows($result) == 1) return 1;

return 0;
}

PHP Exercise - Out of Office Calendar

April 22, 2008 – 1:02 pm

Your office requires a web-based Out of Office Calendar showing what staff are present or absent over a fornight period. The table-based calendar should date back to the previous Monday and display staff entries for two weeks. Staff can login and choose a date from a drop-down list and set the type of Absence they are planning (O/B, V, O/B am, O/B pm, V am, V pm). Staff must login to change their details.

Create a database with at least 10 users, each with a username and encrypted password.

A user must login in order to view the timetable. Failed logins redirect to the login page.

A logout link must be availalbe. When the user logs out, the program redirects back to the login page.

PHP - MySQL Class Day 3/4 (21-04-08)

April 22, 2008 – 8:03 am

String Handling and Theory

Date Handling and Theory

Timetable Exercise