Jump to content

PHP login system with MySQL need help.


iStriide

Recommended Posts

i have already made the register page where their info goes into the database, and im not sure about the code that selects values from the database.

mysql_connect('', '', '');
mysql_select_db('');

$user = $_POST['user'];
$pass = $_POST['pass'];

echo "<font color='white'>You Need To Login</font>";
if($user == Username && $pass == Password) echo "Welcome $user";

mysql_query("SELECT ('Username', 'Password') FROM login");

?>

 

Link to comment
Share on other sites

mysql_connect('', '', '');
mysql_select_db('');

if (isset($_POST['submit'])) {
  $user = mysql_real_escape_string($_POST['user']);
  $pass = mysql_real_escape_string($_POST['pass']);
  $sql = "SELECT id FROM login WHERE username = '$user' && `password` = MD5('$pass')";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      // $user & $pass are valid
    } else {
      // $user || $pass invalid
    }
  }
}

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.