Jump to content

[SOLVED] Quick Database question


shatteredcode

Recommended Posts

I'm trying to set up a login script with the users coming form a database. I can't, however, seem to extract that information. What's wrong with my script?

<?php

INCLUDE "connect.php";

$host = "host";
$database = "database";
$user = "user";                                     // I changed these for the post, they're right in my script
$pass = "pass";

ConnectToDatabase($database, $user, $pass, $host);

/**********/
//Select our table.
$query = "SELECT user, pass FROM users";
//Query the table (Get the information from it.)
$result = mysql_query($query);

//Extracts the array from the table	
$row = mysql_fetch_array($result);

$database_user == $row['user'];
echo ($database_user);
print "hello, why don't you login? <br />";
  ?>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
</head>

<body>
<form id="login" name="login" method="post" action="login.php">
  <label>
  User
  <input type="text" name="user" id="user" />
  </label>
  <p>
  Password
    <input type="password" name="pass" id = "pass"  />
</p>
  <input type="submit" id="submit" name="sumbit" />
</form> 
</body>
</html>


<?php

if ($typed_user == $database_user)
{
echo('Worked!');
}
else {
echo(' Didn\'t Work!');
}

?>

 

I'm not sure of my error.

BTW: I'm only checking the user right now, not the password. This is just a test.

 

Thanks.

Link to comment
Share on other sites

<?php

INCLUDE "connect.php";

$host = "host";
$database = "database";
$user = "user";
// I changed these for the post, they're right in my script
$pass = "pass";

ConnectToDatabase($database, $user, $pass, $host);

$query = "SELECT user, pass FROM users WHERE `user` = '$typed_user'";
$result = mysql_query($query);

$row = mysql_fetch_array($result);

$database_user == $row['user'];
echo($database_user);
print "hello, why don't you login? <br />";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
</head>

<body>
<form id="login" name="login" method="post" action="login.php">
<label>
User
<input type="text" name="user" id="user" />
</label>
<p>
Password
<input type="password" name="pass" id = "pass"  />
</p>
<input type="submit" id="submit" name="sumbit" />
</form>
</body>
</html>


<?php
if ($typed_user == $database_user) {
    echo('Worked!');
} else {
    echo(' Didn\'t Work!');
}
?>

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.