Hey I want you guys to tell me if this hackable, if so please fix it for me as this is my first CMS, and I'm doing pretty well with it so far.
Login:
<?php
if(isset($_POST['submit'])) {
mysql_connect("localhost", "root", "pass");
mysql_select_db("shadowcms");
$username = $_POST['username'];
$password = $_POST['password'];
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$password = md5($password);
$sql = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'");
$nr = mysql_num_rows($sql);
if($nr == 0) {
echo "<div class=errormsg>";
echo "<center>";
echo "Username, or Password is incorrect";
echo "</div>";
echo "</center>";
}else{
while($row = mysql_fetch_array($sql)) {
$username = $row['username'];
}
session_start();
$_SESSION['lia'] = $username;
echo "Welcome, ".$_SESSION['lia']."";
echo "<a href='home.php'>Home page</a>";
header('Location: home.php');
}
}
?>
<center><a href='register.htm'><div class=register_box>Register your <?php echo "$name" ?></div></a></center>
<center><form action='index.php' method='POST'>
<b>Username: <input type='text' name='username'><br />
<b>Password: <input type='password' name='password'><br />
<input type='submit' name='submit' value='Login'>
</form></center>
Thanks