PHP Classes

File: agolfhandicap.php

Recommend this page to a friend!
  Classes of George Clarke   A Golf Handicap   agolfhandicap.php   Download  
File: agolfhandicap.php
Role: Example script
Content type: text/plain
Description: Example script for AGolfHandicap class
Class: A Golf Handicap
Record played golf games in a MySQL database
Author: By
Last change: Corrected filename in include statement.
Date: 18 years ago
Size: 1,875 bytes


Class file image Download
// This is an example script using the agolfhandicap class to record games played
// and calculate your golf handicap index.
// It is a multi user database and can keep track of games for different players.
// First enter your name or user name then the game information.
// This script really should be used with a user/password login system for security.
// Version 1.1.0: Added Edit and Delete for a record in the database.
// ############ You must edit the username, password and database name further down.

include "class.agolfhandicap.php";
$gh=new agolfhandicap();

// ######### Edit the next line to put your MySQL username, password, and database name. ########

// Get the user name if submitted.
$_POST['delete']){ //delete the record
$_POST['edit']){ //edit the record
// If no user yet, ask for it.
"<form name='usr' action='$PHP_SELF' method='POST'>";
"Enter your user name:<input type='text' name='user' size='20'>";
"<input type='hidden' name='hid' value='true'>";
"<input type='submit' value='Submit' name='submits'>";
// We have a username, so get new game data and display handicap and all games.
print "<h2>Golf Game Database and Handicap Calculator for $user</h2>\n";
$id=($_POST['edit']=="")? "":$id;
print (
$hc==0)?"<h3>You need at least 5 games for a handicap index.</h3>":"<h3>Handicap for $user is $hc</h3><br>";
// If you just want the data without displaying it, use next line.