Ok, so i'll explain the best i can Smiley .. I've found a free php script that uses a DB to store a golf players score and handicap... Problem is, the way the php script is written it doesn't even require the person to be a registered user. It just ask the person to enter a username "so they could make up one if they wanted" and then it uses the username they entered to store the scores in the DB under that name.
So here's my real problem...
I'm trying to integrate this with my website. I have a forum on my website powered by " Vanilla". I would like to setup this script so that only people that are members of the forum can use the script. AND the script will look to see if the user is logged in or not, and if they are, it will us there data as the username for the php script to store the scores etc.. in.
I'm sorry, but i dunno very much about php, anything i try to do right now with php takes hours and hours, i'm learning as much as possible, but i get stuck "with what ya'll would consider easy problems" all the time Undecided .
So if anyone could help point me in the right direction with what i'm trying to do i will be forever in debt. Grin
Below is the php script and the SQL that came with it.
First things first, i need to figure out the best place to put the SQL tables, since i'm trying to use the vanilla username db.
here's the SQL that came with it too.
CREATE TABLE golfhcapu (
id int(11) NOT NULL auto_increment,
user varchar(30) NOT NULL default '',
course varchar(50) default NULL,
date varchar(10) NOT NULL default '',
score int(11) NOT NULL default '0',
crating decimal(11,1) NOT NULL default '0.0',
srating int(11) default NULL,
hcapdiff decimal(11,1) NOT NULL default '0.0',
PRIMARY KEY (id)
) TYPE=MyISAM AUTO_INCREMENT=16 ;
There are 2 php files for this script, here they are below.
1. agolfhandicap.php
2. class.agolfhandicap.php "in the next post"
<?php
// 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. ########
$gh->setupdb('','','');
// Get the user name if submitted.
if($_POST['user']){
$user=$_POST['user'];
$gh->setuser($user);
}
if($_POST['delete']){ //delete the record
$id=$_POST['id'];
$gh->deleteGame($id);
}
if($_POST['edit']){ //edit the record
$id=$_POST['id'];
}
// If no user yet, ask for it.
if(!isset($_POST['user'])){
print "<form name='usr' action='$PHP_SELF' method='POST'>";
print "Enter your user name:<input type='text' name='user' size='20'>";
print "<input type='hidden' name='hid' value='true'>";
print "<input type='submit' value='Submit' name='submits'>";
print "</form>";
}else{
// 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";
$newgame=$gh->getnewgame($id);
$id=($_POST['edit']=="")? "":$id;
$gh->showform($id);
$hc=$gh->gethcap();
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.
//$al=$gh->getAll();
$gh->showall();
}
?>
The other script that goes with this is in the next post...
And here are the resources..
Demo of script as is.. http://www.gaclarke.com/agolfhandicap/handicapu.php
and where the script came from.. http://phpclasses.promoxy.com/browse/package/2546.html
And here's my golf site I'm trying to integrate this with... http://www.ncgolfers.com
So, I guess I need to somehow take the current user session that vanilla is using and apply it to this script. That's about all that needs to be done i guess right?? 😛
Thank you very much,
Wayne