Jump to content


Photo

Some help needed for a login page..


  • Please log in to reply
6 replies to this topic

#1 SpriteSODA

SpriteSODA
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 20 July 2006 - 08:16 PM

Well, im sure that there is all the data needed. the echo command during the loop is my experiment, which shows that no data gets in to $row['username'] and $row['password'] and thats so bizzare becuase the data is surely there.
you can also watch it here http://shaymaz0r.phpnet.us/login.php .
user 111 pass 111 is in the DB so you can see the problem.
this is the code:
<?
if ($_POST['submit'])
{
  mysql_connect('xxx','dasdasdas','sdasda');
  mysql_select_db('shaymaz0r');
  $query=mysql_query("SELECT * FROM tblusers");
  $user=$_POST['username'];
  $pass=$_POST['password'];
  $ok=0;
  while ($row = mysql_fetch_array($query) && $ok==0)
  {
    $dbuser=$row['username'];
    $dbpass=$row['password'];
    echo("$dbuser $dbpass |||");
    if ($user==$dbuser) 
    {
      if ($pass==$dbpass) {
        $cookievalue=$row['ID'];
        setcookie("soda", $cookievalue);
        header('Location: http://shaymaz0r.phpnet.us/main.php');
      } else { $ok=1; }
    }
  }
  if ($ok==1)
  {
    echo("<h3 color='red'>Wrong Password.</h3>");
  }
  else { echo("<h3 color='red'>Wrong Username.</h3>"); }
  mysql_close();
}

?>


<html>
<head>
<title>Login page</title>
</head>
<body>
<center>
<br><br>
<h1>Login Page</h1>
<br>
<form method="post" action="login.php">
<h2>Username:</h2><input type="text" name="username"><br>
<h2>Password:</h2><input type="password" name="password"><br>
<h2><input type="submit" value="Login Now" name="submit"></h2>
</form>
</body>
</html>

thank you very much.

#2 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 20 July 2006 - 08:21 PM

dont really now what ur database is like but the only thing i can see is misspelling of database fields or capitalization try echoing the database results in the while statement and see what happens

while ($row = mysql_fetch_array($query) && $ok==0)
  {
    $dbuser=$row['username'];
    $dbpass=$row['password'];
    echo "$row['username']";
echo "$row['password']";
    {

"Syntax error" .. WHERE THE **** IS IT?!

#3 cmgmyr

cmgmyr
  • Members
  • PipPipPip
  • Advanced Member
  • 1,278 posts
  • LocationUSA

Posted 20 July 2006 - 08:22 PM

I hope that isn't your real connect information...if it is, I would edit that out ASAP!!!

#4 SpriteSODA

SpriteSODA
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 20 July 2006 - 08:30 PM

what? 111? no its just for test. and of course the user and pass of the mysql_connect is also just a blob =P

#5 cmgmyr

cmgmyr
  • Members
  • PipPipPip
  • Advanced Member
  • 1,278 posts
  • LocationUSA

Posted 20 July 2006 - 08:33 PM

no your mysql_connect it just looked like host generated information...Just trying to save your skin if it was your real info  :)

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 20 July 2006 - 08:34 PM

I have change it to 'xxx'

#7 SpriteSODA

SpriteSODA
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 20 July 2006 - 08:53 PM

dont really now what ur database is like but the only thing i can see is misspelling of database fields or capitalization try echoing the database results in the while statement and see what happens

while ($row = mysql_fetch_array($query) && $ok==0)
  {
    $dbuser=$row['username'];
    $dbpass=$row['password'];
    echo "$row['username']";
echo "$row['password']";
    {


well, if I try doing your advice its sending an error - Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/shaymaz0r/www/login.php on line 14

its so bizzare.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users