Jump to content

Archived

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

tbobker

Help what is wrong with my login script

Recommended Posts

What is wrong with this?

Here is my login part:

[code]<html>
<body>

<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">
</form>
</div>

</body>
</html>[/code]


and here is the login script:

[code]<?php

include("dbconnect.inc");

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



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

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.