Little help please with my project

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DeadlyMan
Forum Newbie
Posts: 2
Joined: Sat Oct 09, 2010 6:08 pm

Little help please with my project

Post by DeadlyMan »

HI

I'M MAKING SMALL PROJECT AND I HAVE SOME PROBLEM WITH MY PROJECT

THAT I WANT TO KNOW IF USER IN DATABASE AND IF THE USER IS IS

THE PHP PRINT SUCCESS MESSAGE AND GIVE ME INFO ABOUT THE USE

HERE MY CODING

Code: Select all


<?php

include("./db.php");
 $link = mysql_connect($server, $user, $pass);
 if(!mysql_select_db($database)) die(mysql_error());

$result = mysql_query("SELECT * FROM `members`");
$r = mysql_fetch_array($result);

$username = $r['username'];
$password = $r['password'];
$email = $r['email'];

//$keya=md5($_GET["key"]);

if (isset($_GET["key"]))  {

   $key = $_GET["key"];


			 $q = "SELECT username FROM `members` WHERE (username = '$key')";
             if(!($result_set = mysql_query($q))) die(mysql_error());
             $number = mysql_num_rows($result_set);

             if ($number) {
                 
				print "USER FOUND  !"; 
				print "</br>";
				print "Mr  $username";
				print "</br>";
				print $password;
				print "</br>";
				print $email;
                 
             }
             else {
				print "Sorry ! User Not Found "; 
}
}
?>

AND THE SQL IS IN ATTACH
Attachments
members.zip
(715 Bytes) Downloaded 114 times
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: Little help please with my project

Post by internet-solution »

Go easy on the CAPS !

Your code gets the information for the first row returned by mysql_fetch_array(). You need to get the information for the selected user.

You don't really need the first query and place the So put the following code after if ($number) {

Code: Select all

$r = mysql_fetch_array($result_set);

$username = $r['username'];
$password = $r['password'];
$email = $r['email'];
DeadlyMan
Forum Newbie
Posts: 2
Joined: Sat Oct 09, 2010 6:08 pm

Re: Little help please with my project

Post by DeadlyMan »

thanx 4 this help it's cool
Post Reply