login script *rips hair out*
Posted: Mon Dec 01, 2003 10:39 pm
i have set up a registration script to write registation info to a database, now i need to beable to let that user login, but i cant get this to work
the table "names" is in the database "complexscripting" and the usernames and passwords are stored in the fields "username" and "password" respectivly.
heres what i have
login.html
login.php
once i get it to check the database for the users and such ill have it write a cookie that defines login but i just want to get the basic script to work
when i run the script i dont get any errors it just wont say im loged in, no matter what it says not found in database!
as usual any help is greatly appreciated!
the table "names" is in the database "complexscripting" and the usernames and passwords are stored in the fields "username" and "password" respectivly.
heres what i have
login.html
Code: Select all
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css"/>
<script type="text/javascript" src="fader.js"></script>
</head>
<body> <table width='100%' height='100%' border='0' cellspacing='1' cellpadding='2' bgcolor='#dcdcdc' align='center'>
<tr><td width='200' border='1' bgcolor='whitesmoke'>Login
</td></tr><tr><td width='200' border='1' bgcolor='#ffffff'><form action='login.php' method='post'>
Enter UserName: <input type="text" name="user">
<br>
Enter Password: <input type="password" name="password">
<br>
<input type='submit' value='submit'></form>
<br>
<a href='register.html' target='main'>Have you registered yet?</a>
</td></tr></table>
</body>
</html>Code: Select all
<?php
$dbhost = 'www.freesql.org';
$dbusername = '*************';
$dbpasswd = '***********';
$database_name = 'complexscripting';
$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");
$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
$username = $_POST['user'];
$password = md5($_POST['password']);
$db_username = mysql_query("SELECT username FROM users");
$db_password = mysql_query("SELECT password FROM users");
if (($username == $db_username) && ($password == $db_password)){
echo "login complete";
}
else{
echo "not found in database! please register!";
}
?>when i run the script i dont get any errors it just wont say im loged in, no matter what it says not found in database!
as usual any help is greatly appreciated!