[SOLVED] Login Problem...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

[SOLVED] Login Problem...

Post by Dale »

On my home pc using localhost this works but now for some reason when i put it on the net it doesnt work... could you try and help me find out why please :D
index.php

Code: Select all

<form action="veri.php" method="POST">
<table border="0" width="50%" cellspacing="1" cellpadding="4" bgcolor="#000000">
<tr valign="top">
<td width="100%" bgcolor="#456789" align="center" colspan="2"><font face="verdana" size="3" color="#FFFFFF"><b>D-Frame.co.uk Control Panel Login...</b></font></td>
</tr>
<tr>
<td width="35%" bgcolor="#F9F9F9" align="center"><font face="verdana" size="2">Username:</font><br><font face="verdana" size="1">[<a href="./register.php">Register</a>]</font></td>
<td width="65%" bgcolor="#F9F9F9" align="center"><input type="text" name="username"></td>
</tr>
<tr>
<td width="35%" bgcolor="#F9F9F9" align="center"><font face="verdana" size="2">Password:</font></td>
<td width="65%" bgcolor="#F9F9F9" align="center"><input type="password" name="password"></td>
</tr>
<tr valign="top">
<td width="100%" bgcolor="#345678" align="center" colspan="2"><input type="submit" value="Login..."></td>
</tr>
</table>
</form>
veri.php

Code: Select all

<?php
if ((!$_POST[username]) || (!$_POST[password])) {
?>
<html>
<head>
<title>D-Frame.co.uk Control Panel Login</title>
</head>

<body bgcolor="#C9C9C9" text="#000000" link="#000000" vlink="#000000" alink="#000000">

<center>

<table border="0" width="50%" cellspacing="1" cellpadding="4" bgcolor="#000000">
<tr valign="top">
<td width="100%" bgcolor="#456789" align="center"><font face="verdana" size="3" color="#FFFFFF"><b>D-Frame.co.uk Control Panel Login...</b></font></td>
</tr>
<tr>
<td width="100%" bgcolor="#F9F9F9" align="center"><font face="verdana" size="2">You didn't fill in all the forms. <a href="./index.php">Go Back</a></font></td>
</tr>
</table>

<font face="verdana" size="1">Copyright &copy;<a href="mailto:dalehay@gmail.com">D-Frame.co.uk</a>, 2004</font>
</center>

</body>
</html>
</php
	exit;
}

$conn = mysql_connect("localhost", "dframe_dale", "********") or die(mysql_error());
mysql_select_db("dframe_dforum",$conn) or die(mysql_error());

// $sql = "SELECT username, password FROM users WHERE username = '$_POST[username]' AND password = password('$_POST[password]')";
$result = mysql_query($sql,$conn) or die(mysql_error());

if (mysql_num_rows($result) == 1) {
$username = mysql_result($result, 0, 'username');

// I god damn hate cookies!

setcookie("access", "1", time()+3600, "/", "d-frame.co.uk", 0);

// OH for fu.. bleedin hell, not only does this require cookies but SESSIONs TOO! *grumbles*

session_start();

$_SESSION[username] = "$_POST[username]";
?>
<html>
<head>
<title>D-Frame.co.uk Control Panel Login</title>
</head>

<body bgcolor="#C9C9C9" text="#000000" link="#000000" vlink="#000000" alink="#000000">

<center>

<table border="0" width="50%" cellspacing="1" cellpadding="4" bgcolor="#000000">
<tr valign="top">
<td width="100%" bgcolor="#456789" align="center"><font face="verdana" size="3" color="#FFFFFF"><b>D-Frame.co.uk Control Panel Login...</b></font></td>
</tr>
<tr>
<td width="100%" bgcolor="#F9F9F9" align="center"><font face="verdana" size="2">Thanks <?php echo "$_SESSION[username]"; ?> for logging in!<br>[<a href="./membercp/">Proceed...</a>]</font></td>
</tr>
</table>

<font face="verdana" size="1">Copyright &copy;<a href="mailto:dalehay@gmail.com">D-Frame.co.uk</a>, 2004</font>
</center>

</body>
</html>
<?php
} else {
?>
<html>
<head>
<title>D-Frame.co.uk Control Panel Login</title>
</head>

<body bgcolor="#C9C9C9" text="#000000" link="#000000" vlink="#000000" alink="#000000">

<center>

<table border="0" width="50%" cellspacing="1" cellpadding="4" bgcolor="#000000">
<tr valign="top">
<td width="100%" bgcolor="#456789" align="center"><font face="verdana" size="3" color="#FFFFFF"><b>D-Frame.co.uk Control Panel Login...</b></font></td>
</tr>
<tr>
<td width="100%" bgcolor="#F9F9F9" align="center"><font face="verdana" size="2">We couldn't log you in because either the username or password you supplied couldn't be found in the database. <a href="./index.php">Go Back</a></font></td>
</tr>
</table>

<font face="verdana" size="1">Copyright &copy;<a href="mailto:dalehay@gmail.com">D-Frame.co.uk</a>, 2004</font>
</center>

</body>
</html>
<?php
exit;
}
?>
Now when i log in i always get the We couldn't log you in because either the username or password you supplied couldn't be found in the database. error which for some reason seems wrong, considering im entering the correct data.
Last edited by Dale on Mon Sep 20, 2004 5:41 am, edited 2 times in total.
User avatar
Daemon_B
Forum Newbie
Posts: 13
Joined: Mon Sep 20, 2004 1:08 am

Post by Daemon_B »

Hello,

LMAO

Look at line 23 - </php

Try changing it to <?php
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Woops... lol, just a silly little typo... thanks Daemon_B :D
Post Reply