PHP 2 kişi aynı bilgisayar pt.02 aynı anda giriş

0 Cevap php

Bu bir oturum açma komut olarak iyi görünüyor

//Player 1 Login username and password
$p1name = $_POST['p1name'];
$p1pass = $_POST['p1pass'];

//player 2 Login username and password
$p2name = $_POST['p2name'];
$p2pass = $_POST['p2pass'];

$connection = mysql_connect("db_host", "db_user", "db_pass");
mysql_select_db("db_name", $connection);

get_user($p1name, $p1pass);
get_user($p2name, $p2pass);

$row = $result;
$found = false;

if(($row["username"] == $p1name && $row["password"] == sha1("$p1pass")) 
   && ($row["username"] == $p2name && $row["password"] == sha1("$p2pass")))
{
  $found = true;
  break;
}

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);
}

0 Cevap