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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.