Thanks. I'm not storing my results.
I can't figure out:
1) How to get the IP?
2) How to insert it into my table.
Here's my code all of mySQL/PHP queries at the top of the page.
<?
require ( "database_conn.inc.php" );
// First, check whether the add vote form was submitted
if ( $_POST['add_votes'] ) {
foreach ( $_POST as $key => $val ) {
if ( eregi ( "rating", $key ) ) {
$player_rating = explode ( "_", $val );
$sql = 'INSERT INTO rating ( player_id, match_id, rating_value ) VALUES (' . $player_rating[0] . ',' . $_POST['match_id'] . ',' . $player_rating[1] . ')';
$add_rating_rs = $conn->Execute($sql) or die ( $conn->ErrorMsg() );
}
}
header ( "Location: results.php?match_id=" . $_POST['match_id'] );
exit;
}
// Now check whether the match passed in is the most recent. If it is, carry on to the voting page
// otherwise redirect to the results page for the match in question.
$latest_match_rs = $conn->Execute ( "SELECT match_date FROM matches ORDER BY match_date ASC LIMIT 0,1") or die ( $conn->ErrorMsg() );
$latest_match_timestamp = $latest_match_rs->Fields("match_date");
$match_rs = $conn->Execute ( "SELECT * FROM matches, team WHERE matches.match_opponent=team.team_id AND matches.match_id=" . $_GET['match_id'] ) or die ( $conn->ErrorMsg() );
$this_match_timestamp = $match_rs->Fields("match_date");
// Now redirect to the results page if there is a match to vote on later than the one passed in
if ( $latest_match_timestamp > $this_match_timestamp ) {
header ( "Location: results.php?match_id=" . $match_rs->Fields("match_date") );
exit;
}
$arse_squad_rs = $conn->Execute ( "SELECT * FROM player, match_squad WHERE match_squad.team_id=1 AND match_id=" . $_GET['match_id'] . " AND match_squad.player_id=player.player_id ORDER BY player_position ASC" ) or die ( $conn->ErrorMsg() );
$sub_on = $arse_squad_rs->Fields("match_sub_on_min");
$sub_off = $arse_squad_rs->Fields("match_sub_off_min");
$playerid = $arse_squad_rs->Fields("player_id");
$match_type_rs = $conn->Execute ( "SELECT * FROM type_match, matches WHERE matches.match_type=type_match.type_id AND matches.match_id=" . $_GET['match_id'] . "" ) or die ( $conn->ErrorMsg() );
$typeofmatch = $match_type_rs->Fields("type_name");
?>
Then at the bottom, by the submit button I have:
<td width="91" bgcolor="cc0033" align="center" valign="middle"><input name="add_votes" type="submit" id="add_votes" value="Submit" class="bttn">
<input name="match_id" type="hidden" id="match_id" value="<?=($_GET['match_id'])?>"></td>
Thanks for helping me out.