I have this code:
<html> <head> <?php include "header.php"; ?> </head> <body> <p> <div id="dialog"> <?php if(isset($_POST['submit'])){ $username = $_POST['name']; $password = $_POST['password']; $md5_password = md5($password); if(isset($username)&&isset($password)){ $account = mysql_query("SELECT name FROM users WHERE name='$username' AND pass='$md5_password'"); //LINE 14 --- OVER HERE if(mysql_num_rows($account)>0){ echo "Successfully logged in."; } else{ echo "Wrong username or password."; } } else{ echo "Please fill in all the details."; } } else { echo "Login to Mini Universe to get cool site extras!"; } ?> </div> <br /> <form method="post" action="login.php"> <input type="text" name="name" value="Username" maxlength="25" /><br /><br /> <input type="text" name="password" value="Password" maxlength="25" /><br /><br /> <input type="submit" name="submit" value="Login" /> </form> </p> </body> </html>
Its a login form for my site, but it doesn't seem to work at line 14, instead when I try to login with my registered account, I get "Wrong username or password". Help appreciated. Thanks.
Offline
If this is your first time creating a login system, you should try using files instead of MySQL, as it is much easier.
Also, if you are using MySQL, you should use MySQLi instaed.
Offline
I agree with jvvg.
Or you could use SQlite which is supposed to be easier.
Offline
jji7skyline wrote:
I agree with jvvg.
Or you could use SQlite which is supposed to be easier.
Actually, SQLite is about the same as MySQL in terms of difficulty. The only difference is that the SQLite database is stored locally in a file, and MySQL is on a server. In terms of programming syntax, the queries are exactly the same.
That's why my older sites use files instead of MySQL.
Offline
Look, when I post a question asking for help, I DON'T want to go off and change it completely and use files, I just want a simple answer. And yes, I have made one before. If your gonna go off topic do it somewhere else.
Offline
SELECT name FROM users only selects the names. Try using SELECT * FROM users.
Offline