<?php
/*session_start();*/
$username = $_POST['username'];
$password = $_POST['password'];
if($username&&$password)
{
$connect = mysql_connect("non", "non", "non") or die ("Couldn't connect!");
$selectdb = mysql_select_db("non") or die ("Couldn't select database!");
$query = mysql_query("SELECT * FROM users WHERE Username='$username'");
$numrows = mysql_num_rows($query);
if($numrows!=0)
{
//check for login
while($row = mysql_fetch_assoc($query))
{
$dbusername = $row['Username'];
$dbpassword = $row['Password'];
}
//check if the match!
if($username==$dbusername&&md5($password)==$dbpassword)
{
$_SESSION['username']=$username;
echo $row['Username'];
$query1 = mysql_query("SELECT * FROM users WHERE Username='$username'");
$assoc = mysql_fetch_assoc($query1);
echo "Welcome <b>".$assoc['Username']."</b>";
echo "<p>";
echo "<br>";
echo "You currently have <b>".$assoc['Kills']."</b> kills and <b>".$assoc['Deaths']."</b> deaths.";
echo "<br>";
echo "<p>";
if($assoc['Admin Level'] == 1)
{
echo "You are <b>Moderator!</b>";
}
if($assoc['Admin Level'] == 2)
{
echo "You are <b>Administrator!</b>";
}
if($assoc['Admin Level'] == 3)
{
echo "You are <b>Server Owner!</b>";
}
if($assoc['VIP'] == 1)
{
echo "<br>";
echo "<p>";
echo "You are <b>VIP Member!</b>";
}
echo "<br>";
echo "<p>";
echo "<a href='logout.php'>Logout!</a>";
if($assoc['Admin Level'] == 0)
{
echo "<br>";
echo "<p>";
echo "<a href='ModeratorApplications.php'>Moderator Applications</a>";
}
if($assoc['Admin Level'] == 3)
{
echo "<br>";
echo "<a href='modadmin.php'>Look For New Moderator Applications!</a>";
}
if($assoc['Admin Level'] == 2)
{
echo "You are <b>Server Owner!</b>";
echo "<br>";
echo "<a href='modadmin.php'>Look For New Moderator Applications!</a>";
}
}
else
echo "Incorrect password!";
}
else
die("That user doesn't exist!");
}
else
die("Please enter and username and password!");
?>

$row = mysql_fetch_array($query);
(mysql_fetch_assoc looks like mysql_fetch_array.. oh well.)$query = mysql_query("SELECT * FROM users WHERE username='$_POST[username]'");
if(mysql_num_rows($query) == 0)
{
// no results
die('Username not found');
} else {
$fetch = mysql_fetch_array($query);
if(md5($_POST['password'] === $fetch['password']))
{
// a result and log the user in by means of a session
$_SESSION['username'] == $_POST['username'];
} else {
die('Wrong password');
}
}

$query4 = mysql_query("UPDATE users SET `Admin Level` = `1` WHERE `Username` = '$user'");
if(!mysql_query(query4))
{
echo mysql_error();
}
|
Originally Posted by Ironboy500
Код:
$query4 = mysql_query("UPDATE users SET `Admin Level` = `1` WHERE `Username` = '$user'");
if(!mysql_query(query4))
{
echo mysql_error();
}
|
$query4 = mysql_query("UPDATE users SET `Admin Level` = `1` WHERE `Username` = '$user'");
if(!mysql_query($query4))
{
echo mysql_error();
}
|
Originally Posted by Matthias_
Uhm, I don't think you can have a space in the fieldname
|
|
Originally Posted by ┤ŞąiBЄЯҒПŋ├
Quote:
if(!mysql_query($query4)) instead of if(!mysql_query(query4)) Код:
$query4 = mysql_query("UPDATE users SET `Admin Level` = `1` WHERE `Username` = '$user'");
if(!mysql_query($query4))
{
echo mysql_error();
}
|
) that it matters if you put single quotes and .. those weird quotes
heh.. together.
mysql_query('UPDATE `users` SET AdminLevel = "1" WHERE Username = "'.$user.'"');
$query4 = mysql_query('UPDATE `users` SET AdminLevel = "1" WHERE Username = "'.$user.'"');
if(!$query4)
{
echo mysql_error();
}
if($query4 == 0)
{
code
}
|
Originally Posted by Seif_
You can't use ` and ' in the same query, it will return an error.
|
|
Originally Posted by Seif_
Quote:
PHP код:
|