Jump to content

Checking name and password with php


pinacoladaxb

Recommended Posts

I just started using php today, so please don't use any big words on me. :D

 

Anyway, I made an application that has a login system. I want it to be able to interact with a MySQL database and check if a login is correct. To do this, I know I need to use php because MySQL can only interact directly with files on the same server. Well, here's the code I wrote that checks if a username and password match:

 

<html>
<head>
<title>User Check</title>
</head>
<?

$name = $_GET['name'];
$userpassword = $_GET['userpassword'];

$service = "localhost";
$username = "pauliuko";
$password = "sdfsfsf";
$database = "pauliuko_games";

mysql_connect($service, $username, $password);
@mysql_select_db($database) or die( "Unable to select database");


$get=mysql_query("SELECT (id) FROM users WHERE name=$user and password=$pass");
$result=mysql_query($query);
echo"$result"



?>


</body>


</html>

 

If the name and password match, there should be a "1" on the screen, but when I try it, the page is blank. What did I do wrong? My MySQL table has 4 columns: id, name, password, and datejoined. Could someone tell me how to fix this? I would be posting this under php help, but that forum isn't working at the moment.

Link to comment
https://forums.phpfreaks.com/topic/103500-checking-name-and-password-with-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.