creativkook Posted March 5, 2006 Share Posted March 5, 2006 I have a script for a log in that works on another database and site, but doesn't seem to agree with the one I'm trying to get it set up on. Can anyone tell me what can be causing this problem and what I need to do to fix it? Here's the code:<?php$username = $_POST['username'];$password = $_POST['password'];if(isset($_POST['login'])){ require("dbheader.php"); $person = mysql_query("SELECT * FROM cafeusers WHERE username = $username AND password = MD5('$password')"); if(mysql_num_rows($person) > 0) { session_start(); $_SESSION['userid'] = $person['userid']; header("location: home.php"); } else { $error = true; }}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link href="style2.css" rel="stylesheet" type="text/css" /> <title>Login Page</title></head><body><div class="login"><?phpif($error == true){ echo("<p>Username or password invalid.</p>");}?><form method="post" action="<?=$_SERVER['PHP_SELF'];?>"><p>Username: <input type="text" name="username" value="<?=$_POST['username'];?>" /></p><p>Password: <input type="password" name="password" /></p><p><input type="submit" name="login" value="Login" /></p></form></div></body></html> Quote Link to comment Share on other sites More sharing options...
zq29 Posted March 5, 2006 Share Posted March 5, 2006 Try changing this line:[code]$person = mysql_query("SELECT * FROM cafeusers WHERE username = '$username' AND password = MD5('$password')") or die(mysql_error());[/code] Quote Link to comment Share on other sites More sharing options...
creativkook Posted March 7, 2006 Author Share Posted March 7, 2006 [!--quoteo(post=351804:date=Mar 5 2006, 04:29 AM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Mar 5 2006, 04:29 AM) [snapback]351804[/snapback][/div][div class=\'quotemain\'][!--quotec--]Try changing this line:[code]$person = mysql_query("SELECT * FROM cafeusers WHERE username = '$username' AND password = MD5('$password')") or die(mysql_error());[/code][/quote]I tried messing with that line before. Does anyone have any suggestions on how that line should be changed? It just doesn't let me log in. Quote Link to comment Share on other sites More sharing options...
XenoPhage Posted March 7, 2006 Share Posted March 7, 2006 [!--quoteo(post=352386:date=Mar 6 2006, 11:09 PM:name=creativkook)--][div class=\'quotetop\']QUOTE(creativkook @ Mar 6 2006, 11:09 PM) [snapback]352386[/snapback][/div][div class=\'quotemain\'][!--quotec--]I tried messing with that line before. Does anyone have any suggestions on how that line should be changed? It just doesn't let me log in.[/quote]SemiApocalyptic is asking you to add in the die() portion of the query. This way, if the failure is due to the query, you'll get an error that may hint towards a solution.Posting the current output may help us determine what's wrong as well since we can't see your database... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.