diff --git a/includes/login.inc b/includes/login.inc index c6a20d5..fb691df 100644 --- a/includes/login.inc +++ b/includes/login.inc @@ -13,7 +13,8 @@ else if (isset($_POST['do']) == "authenticate") # Attempt login require "dbconnect.php"; - $sql = "SELECT id,username FROM blog_users WHERE username='$_POST[username]' and password=PASSWORD('$_POST[password]')"; + $pass = md5($_POST['password']); + $sql = "SELECT id,username FROM blog_users WHERE username='$_POST[username]' and password='$pass'"; $result = mysql_query($sql) or die (mysql_error()); # echo "Results: " . mysql_num_rows($result); // Debugging line diff --git a/install.php b/install.php index 484f4f2..bfd64ba 100644 --- a/install.php +++ b/install.php @@ -5,8 +5,18 @@ include "includes/config.php"; ?>

Installer

+
+Desired password for admin: +
+ +
"; -} else { +} +else +{ echo "Table 'Blog' created successfully.
"; } # Try to create 'blog_users' table -$sql = "CREATE TABLE `blog_users` (`id` int(11) NOT NULL AUTO_INCREMENT,`username` varchar(20) NOT NULL,`name` varchar(40) NOT NULL,`password` varchar(64) NOT NULL,`session` int(64), PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; +$sql = "CREATE TABLE `blog_users` (`id` int(11) NOT NULL AUTO_INCREMENT,`username` varchar(20) UNIQUE NOT NULL,`name` varchar(40) NOT NULL,`password` varchar(64) NOT NULL,`session` int(64), PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $result = mysql_query($sql); -if (mysql_error()) { +if (mysql_error()) +{ echo mysql_error() . ".
"; -} else { +} +else +{ echo "Table 'Users' created successfully.
"; } # Try to create 'admin' user -$sql = "INSERT INTO `blog_users` (`id`, `username`, `name`, `password`, `session`) VALUES (NULL, 'admin', 'Admin', PASSWORD('admin'), NULL);"; +$sql = "INSERT INTO `blog_users` (`id`, `username`, `name`, `password`, `session`) VALUES (NULL, 'admin', 'Admin', '$pw', NULL);"; $result = mysql_query($sql); -if (mysql_error()) { - echo "User 'admin' already exists.
"; -} else { - echo "User 'admin/admin' created successfully.
"; +if (mysql_error()) +{ + echo mysql_error() . ".
"; +} +else +{ + echo "User 'admin' created successfully.
"; } end_html();