3 Replies - 453 Views - Last Post: 29 January 2010 - 06:58 PM Rate Topic: -----

#1 NemY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 27-January 10

MySQL/PHP Help

Posted 29 January 2010 - 03:27 PM

I'm trying to see if there is a certain value in the colum "Usernames". But I wouldn't know where to start. I know I would use an if statement. That's about it.

Could someone supply me with a snippet of code? Or perhaps a tutorial on how to do this?


By the way, if you know Lua then this is basicly what I want to do.

inputtedname = "None"
usernames = {"None","1","HHEEEE"}
for i = 1, #usernames do
if usernames[i] == inputtedname then
--Do something
end
end


This post has been edited by NemY: 29 January 2010 - 03:33 PM


Is This A Good Question/Topic? 0
  • +

Replies To: MySQL/PHP Help

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,496
  • Joined: 23-August 08

Re: MySQL/PHP Help

Posted 29 January 2010 - 04:01 PM

You need to go read this SQL tutorial
SELECT * FROM tablename where Usernames='the_data_for_which_you_are_looking'

Was This Post Helpful? 1
  • +
  • -

#3 NemY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 27-January 10

Re: MySQL/PHP Help

Posted 29 January 2010 - 04:34 PM

<?PHP

	$user_name = "root";
	$passwor = "";
	$database = "login";
	$server = "localhost";

$db_handle = mysql_connect($server, $user_name, $passwor);
$db_found = mysql_select_db($database, $db_handle);
$name = $_POST['LoginName'];
$password = $_POST['LoginPass'];
$realpass = md5('$password');

$result = mysql_query("SELECT * FROM members WHERE username='$name'")
or die(mysql_error()); 
 

while($row = mysql_fetch_array($result)) {
	if($row['password'] = $realpass){
		echo $row['username']. "-" .$row['password'];
	}
	else{
		echo "Sorry";
	}
} 

?>




Why doesn't that work? It always lets me view the password. Even if the one I specified was wrong.

This post has been edited by NemY: 29 January 2010 - 05:00 PM

Was This Post Helpful? 0
  • +
  • -

#4 JBrace1990  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 110
  • View blog
  • Posts: 760
  • Joined: 09-March 08

Re: MySQL/PHP Help

Posted 29 January 2010 - 06:58 PM

you ned to add "AND WHERE password = '$password'"
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1