Jump to content

Recommended Posts

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:
[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>
[/code]

thank you very much.
Link to comment
https://forums.phpfreaks.com/topic/15192-some-help-needed-for-a-login-page/
Share on other sites

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']";
    {
[quote author=legohead6 link=topic=101301.msg400735#msg400735 date=1153426865]
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']";
    {

[/quote]

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.