Example #1
0
function doJoinTeam($playerName, $team, $password)
{
    if (checkPassword($team, $password, "JOINTEAM") == false) {
        return "Password is incorrect";
    }
    if (isPlayerInTeam($playerName, $team) == true) {
        return "You can't join the same team twice you know?";
    }
    $pid = getPid($playerName);
    if ($pid == 0) {
        return "Error";
    }
    $tid = getTid($team);
    $query = "insert into team_members values ('{$tid}', '{$pid}')";
    $result = mysql_query($query);
    if (mysql_affected_rows() != 1) {
        return "Database error";
    }
    return "OK";
}
<?php

/*
 * $Id$
 *
 * Copyright (c) 1998-2008 John Morrison.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
?>

<?php 
if (isPlayerInTeam($userdata['username'], $name) == true) {
    echo "To leave this team click <a href=\"leaveteam.php?name=" . $name . "\"> here</a>.";
} else {
    echo "<form action=\"jointeam.php?name=" . $name . "\" method=\"POST\">I wish to join this team. Enter team join password: <input type=password name=\"password\" size=10>&nbsp;<input type=submit value=\"Join\"></form><P>";
}
echo "<form action=\"teammodify.php?name=" . $name . "\" method=\"POST\">I wish to edit this team. Enter team edit password: <input type=password name=\"password\" size=10>&nbsp;<input type=submit value=\"Edit\"></form><P>";