Jump to content


This topic is now archived and is closed to further replies.


Help what is wrong with my login script

Recommended Posts

What is wrong with this?

Here is my login part:


<div align="center">
<form method="post" action="login.php">
Username:&nbsp;<input type="text" name="username"><br>
Password:&nbsp;<input type="text" name="password"><br>
<input type="submit">


and here is the login script:



$sql = "select * from login";
$result = mysql_query($sql, $conn);
$row = mysql_fetch_assoc($result);

if($_POST[username] && $_POST[password] == $row[username] && $row[password]){
else {
echo "wrong login <a href='index.html'>Go back</a>";

Why isnt it working? there are no errors just wont login.

Share this post

Link to post
Share on other sites
Try $row[0]['username'] etc...

the best thing to do if that doesn't work is print_r($row) which will show you the data structure of the array so you can code accordingly.

Good luck.

Share this post

Link to post
Share on other sites


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.