9tglhe6nwj Posted February 23, 2011 Share Posted February 23, 2011 Okay, so below I have posted my code, the problem I am having is not knowing how PDO works that well. So what I have attempted to do here is use SQL to check if the user and password are correct, but I'm not sure how to carry on. I realize I have to determine if the database found the matching password and/or username but I have no idea how, any help will be much appreciated. <html> <head> <title>Database login</title> <?php if (isset($_POST['submit'])) { print_r($_POST); $password = md5($_POST['password']); echo'<p>'.$password.'</p>'; $username = ($_POST['username']); echo'<p>'.$username.'</p>'; } ?> </head> <body> <?php $db = new PDO('sqlite:login.sqlite'); $login = 'SELECT * FROM login WHERE userid="'.$username.'" AND password="'.$password.'";'; echo'<p>'.$login.'</p>'; $attempt = $db->query($login); ?> <form method="post" action="Db_login.php"> <p>Username:<br /><input type="text" name="username" /> </p> <p>Password:<br /><input type="password" name="password" /></p> <p><input type="submit" name="submit" value="Log In!" /></p> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.