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
https://forums.phpfreaks.com/topic/209765-php-login-system-with-mysql-need-help/
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
    }
  }
}

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.