ユーザー名とパスワードを入力して ucp-home.php ページにログインするログイン ページがあります。ucp-home.php ファイルの冒頭は次のとおりです。
<?php include("sql.php");include("auth.php");
$con = mysql_connect("localhost","axylus","denismm1234");
mysql_query("SET NAMES UTF8");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("velto", $con);
$result = mysql_query("SELECT * FROM users");
while($row = mysql_fetch_array($result))
{
$skin = $row['SkinID'];
$igname = $row['Username'];
$playerid = $row['UID'];
$tls = $row['TLS'];
$phonenumber = $row['Ph'];
$fightingstyle = $row['FightingStyle'];
$pastnames = $row['PastNames'];
$staff = $row['Staff'];
$staff2 = $row['Staff2'];
$staff3 = $row['Staff3'];
$staff4 = $row['Staff4'];
$donor = $row['Donor'];
$driving = $row['Driving'];
$weapon = $row['Weapon'];
$flying = $row['Flying'];
};
mysql_close($con);
問題は、ログインしたユーザー名の行ではなく、最後の行のデータを使用していることです。
ここに私のlog.phpファイルがあります:
<?php
include("sql.php"); //Connect to SQL
session_start(); //Start session for writing
function Fix($str) { //Clean the fields
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
$errmsg = array(); //Array to store errors
$errflag = false; //Error flag
$username = Fix($_POST['username']); //Username
$password = Fix($_POST['password']); //Password
//Check Username
//Check Password
//If there are input validations, redirect back to the registration form
if($errflag) {
$_SESSION['ERRMSG'] = $errmsg;
session_write_close();
header("location: index.php");
exit();
}
//Create SELECT query
$qry = "SELECT * FROM `users` WHERE `Username` = '$username' AND `Password` = '" . md5($password) . "'";
$result = mysql_query($qry);
//Check whether the query was successful or not
if(mysql_num_rows($result) == 1) {
while($row = mysql_fetch_assoc($result)) {
$_SESSION['UID'] = $row['UID'];
$_SESSION['USERNAME'] = $username;
if($_SESSION['Full Name'] = $_SESSION['Full Name']) echo "Success";
session_write_close();
header("location: dashboard.php");
}
} else {
$_SESSION['ERRMSG'] = "Invalid username or password";
session_write_close();
header("location: index-invalid.php");
exit();
}
?>
私の問題が正確に何であるかを理解していただければ幸いです。前もって感謝します。