Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


need different php help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Sun Nov 16, 2008 2:19 pm    Post subject: need different php help Reply with quote

i have been having trouble with my login page at the moment.
when i log in correctly using my username and pass, it says
Code:
Query was empty


here is the source code if anyone can help me

Code:
<?php
session_start();
include'./global.php';
?>
<html>
<head>
<title>My Blog</title>

<link rel="stylesheet" href="style2.css" type="text/css" />

</head>
<body>

<div id="container">

<div id="header">
<center><h1>My Blog</h1></center>
<?php

if($_SESSION['uid']){
$sql99 = "SELECT * FROM users WHERE id = '" . $_SESSION['uid'] . "'";
$res99 = mysql_query($sql99) or die(mysql_error());

while($row99 = mysql_fetch_assoc($res99)){
echo "<p>Welcome, <a href=\"./profile.php?id=" . $row99['id'] . "<b>" . $row99['name'] . "</b></a> | <a href=\"/logout.php\">Logout</a></p>\n";
}
}else {
echo "<p>Welcome, <b>Guest</b> | <a href=\"./reg.php\">Register</a> | <a href=\"./login.php\">Login</a></p>";
}

?>
</div>
   
    <div id="content">
   
 <?php
 
 $errors = array();
 $step = $_GET['step'];
 if($_SESSION['uid']){
 echo "you are already logged in!";
 }else {
 
 if(!$step){
 echo "<form action='login.php?step=2' method='POST'><table border='0'>\n";
 echo "<tr><td>Username: </td><td><input type='text' name='username'></td></tr>\n";
 echo "<tr><td>Password</td><td><input type='password' name='password'></td></tr>\n";
 echo "<tr><td colspan='2' align='right'><input type='submit' name='submit' value='login'></td></tr>\n";
 echo "</table></form>";
 }
 }
 
 $username = $_POST['username'];
 $password = $_POST['password'];
 $username = mysql_real_escape_string($username);
$username = stripslashes($username);

$password = mysql_real_escape_string($password);
$password = stripslashes($password);
 
 if($step == "2"){
if(!$username){
$errors[] = "Please provide a <b>Username</b>\n";
}else{
if(!$password){
$errors[] = "Please provide a <b>Password</b>\n";
}else{
$sql = "SELECT * FROM users WHERE username = '$username'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) > 0){
$sql2 = "SELECT * FROM users WHERE username = '$username' && password='$password'";
$res2 = mysql_query($res2) or die(mysql_error());
if(mysql_num_rows($res2) > 0){

}else{
$errors[] = "The <b>Username</b> and <b>Password</b> do not match!\n";
}
}else{
$errors[] = "The <b>Username</b> you supplied does not exist.\n";
}
}
}

if(count($errors) > 0){
echo "The following errors have occured!\n";
foreach($errors AS $error){
echo $error . "<br>\n";
}
}else{
$sql3 = "SELECT id FROM users WHERE username = '$username'";
$res3 = mysql_query($sql3) or die(mysql_error());

while($row = mysql_fetch_assoc($res3)){
$_SESSION['uid'] = $row['id'];

echo "You have successfully logged in!\n";
}
}

}
 
 ?>
   
   
    </div>
    </div>
</div>

    </body>
    </html>
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Sun Nov 16, 2008 2:49 pm    Post subject: Reply with quote

I use fetch array, works 100x better.
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Sun Nov 16, 2008 2:52 pm    Post subject: Reply with quote

sorry but it still says query was empty.
EDIT:nevermind, i put $res2 where i was meant to put $sql2. lulz.
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Sun Nov 16, 2008 2:56 pm    Post subject: Reply with quote

I would remake your script but im too lazy.
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites