<?php
// Player 1 Login Information
$p1name = $_POST['p1name'];
$p1pass = $_POST['p1pass'];
// Player 1 Login Information
$p2name = $_POST['p2name'];
$p2pass = $_POST['p2pass'];
// Check user information
$player1 = get_user($p1name, $p1pass);
$player2 = get_user($p2name, $p2pass);
// Has any user been found?
$found = array(
'player1' => false,
'player2' => false
);
// Check if use information matches
if($player1['username'] == $p1name && $player1['password'] == $p1pass) {
$found['player1'] = true;
}
if($player2['username'] == $p2name && $player2['password'] == $p2pass) {
$found['player2'] = true;
}
function connect($db_host, $db_name, $db_pass, $db_table) {
$connection = mysql_connect($db_host, $db_name, $db_pass);
mysql_select_db($db_table, $connection);
}
function get_user($username, $password) {
$query = 'SELECT * FROM users';
$query .= ' WHERE username = ' . mysql_real_escape_string($username);
$query .= ' AND password = ' . mysql_real_escape_string(sha1($password));
$result = mysql_query($query);
return mysql_fetch_assoc($result);
}
Вам нужно было создать экземпляры возвращенной пользовательской информации, чтобы сравнить каждого игрока с их собственным.