0

i have problem my login it's not running plzzz help me

<?php
session_start();
require("dbc.php");
if(isset($_POST['submit']))
{

 $username =mysql_real_escape_string( $_POST['username']); 
  $password =mysql_real_escape_string($_POST['password']);


if ($username && $password)
{
    $connect=mysql_connect("127.0.0.1","root","") or die("couldnt connect to database");
    mysql_select_db("login") or die("couldnt find database");
    $query = mysql_query("SELECT * FROM  `users` WHERE `username` ='$username'");

    $numrows = mysql_num_rows($qurey);


    if($numrows !=0) 
    {
    while($row = mysql_fetch_assoc($qurey))
    {
         $dbusername = $row['username'];
         $dbpassword = $row['password'];


         }
         if($username==$dbusername&&$pasword==$dbpassword)
         {
           echo "login succeful. <a href='membersarea.php'> click here to enter the member area</a>";
           $_SESSION['username'] = $dbusername ;
           }

           else

           echo "incorect password";
           }
           else 
            die ("that username dosent exist"); 
           }
         else  die (" please enter the username and password");


}


 ?>
4
Contributors
26
Replies
118
Views
4 Years
Discussion Span
Last Post by aisha.edris1
Featured Replies
  • You have a type in your while loop. while($row = mysql_fetch_assoc($qurey)) Should be while($row = mysql_fetch_assoc($query)) Read More

0

i have problem my login it's not running plzzz help me

Describe your problem, what you have tried and any other relevant info. "It's not running" is just vague.

2

You have a type in your while loop.

 while($row = mysql_fetch_assoc($qurey))

Should be

 while($row = mysql_fetch_assoc($query))
0

hi everyone now i face problem when i try register new username throw the web page it show that the username doesn't exist in my login.php and doesn't add in database here my code
register.php

<?php

error_reporting(0);

   if($_POST['submit'])

{

   $name=$_POST['name'];



   $username=$_POST['username'];

   $password=$_POST['password'];

   $password1=$_POST['password1'];

   $enc_Password=md5($password);



   if($name && $username &&$password &&$password1)

   {

   if(strlen($name)>30)



   {

   echo "your name is too long";

   }

   if(strlen($username)>10)

   {

      echo "your username is too long";

   }

   else

   {

   if(strlen($password)>15 || strlen($password)<6)

   {

      echo "your password must be btween 6 and 15 character";

   }

   if($password == $password1)

   {

       require "dbc.php";

       $query=mysql_query("INSERT INTO users VALUE('','$name','$usearname','$enc_password')");

       die("registeration complete! <a href='index.php'>click here to login</a>");

   }

   else

   {

   echo "password must match";

   }





   }



   }

   else

   echo "all fileds are required";

}













?>

<html>



<form action="register.php" method="POST">

  name:<input type="text" name="name" value="<?php echo "$name"; ?>"> Max Length:30<p>

  username:<input type="text" name="username" value="<?php echo "$username";?>"> Max Length:10<p>

  password:<input type="password" name="password"> Max Length:15<p>

  Re-Enter Password:<input type="password" name="password1"><p>



  <p>



  <input type="submit" name="submit" value="register">







  </form>



</html>
0

it show that the username doesn't exist in my login.php

What exactly does this mean? Does it give you an error message from PHP? Or an error message you've generated?

0

when i register tell regitration complete but when i insert it in my login they tell it dosen't exit and when i'm going to my database it dosen't insert it

0

Check the username that you are inserting. For instance, you declare username variable;

 $username=$_POST['username'];

and yet in your query, you are inserting;

'$usearname' and not $username

First correct that.

0

$query=mysql_query("INSERT INTO users VALUE('','$name','$usearname','$enc_password')");

VALUE should be VALUES too:

$query = mysql_query("INSERT INTO users VALUES ('', '$name', '$username', '$enc_password')");
0

i'm doing some changes in my register.php here the new code but still not been added in my database

<?php
error_reporting(0);
   if($_POST['submit'])
{
   $name=mysql_real_escape_string($_POST['name']);

   $username=mysql_real_escape_string($_POST['username']);
   $password=mysql_real_escape_string($_POST['password']);
   $password1=mysql_real_escape_string($_POST['password1']);
   $enc_Password=md5($password);

   if($name && $username &&$password &&$password1)
   {
   if(strlen($name)>30)

   {
   echo "your name is too long";
   }
   if(strlen($username)>10)
   {
      echo "your username is too long";
   }
   else
   {
   if(strlen($password)>15 || strlen($password)<6)
   {
      echo "your password must be btween 6 and 15 character";
   }
   if($password == $password1)
   {
       require "dbc.php";
       $query = mysql_query("INSERT INTO users VALUES ('', '$name', '$username', '$enc_password')");
       die("registeration complete! <a href='index.php'>click here to login</a>");
   }
   else
   {
   echo "password must match";
   }


   }

   }
   else
   echo "all fileds are required";
}






?>
<html>

<form action="register.php" method="POST">
  name:<input type="text" name="name" value="<?php echo "$name"; ?>"> Max Length:30<p>
  username:<input type="text" name="username" value="<?php echo "$username";?>"> Max Length:10<p>
  password:<input type="password" name="password"> Max Length:15<p>
  Re-Enter Password:<input type="password" name="password1"><p>

  <p>

  <input type="submit" name="submit" value="register">



  </form>

</html>
0

and here my code to connect to database
dbc.php

<?php
mysql_connect("127.0.0.1","root","") or die("couldnt connect to data base");
mysql_select_db("login") or die ("couldnt find data base");
?>

Edited by aisha.edris1: incorrect spelling

0

I suggest to try the following:

$query = mysql_query("INSERT INTO users VALUES ('', '$name', '$username', '$enc_Password')") or die(mysql_error());

Just noticed that you used a capital "P" on line 10. PHP is case-sensitive.

0

It basically means, that the number of values that you are trying to insert do not match the number of columns in the table you are inserting to.

What are the columns names in the table you are inserting the data to?

Edited by pixelsoul

0

my table is

id int auto increment
name varchar (25)
username varchar(25)
password varchar(25)

Edited by pritaeas: Added markdown.

0

You might need to specify the column names in the query then.

$query = mysql_query("INSERT INTO users (id, name, username, password) VALUES ('', '$name', '$username', '$enc_Password')") or die(mysql_error());
0

If id is an auto increment either use this:

INSERT INTO users (NULL, '$name', '$username', '$enc_Password')

or this:

INSERT INTO users (name, username, password) VALUES ('$name', '$username', '$enc_Password')
0

now it insert it in my database but when i login the passwrd i pick up in register they tell incoorect password
i see in my tabels the password is the md5 password when i paste it in my login it works
how can solve this problem?thanx alot for helping

0

Your table column for password is varchar(25). An md5() result is 32 characters long, so it will be truncated and never match. Change the column length.

0

You also need to hash the password value from the login form to match it against the database value. I don't see that happening there.

$password = md5($password);

In addition to that, I am not sure if this typo was ever caught. $pasword?

if($username==$dbusername&&$pasword==$dbpassword)
0

is necessary to md5?in my register can delet it?i'm change the password varchar(15) still can't insert my password that i made they want the md5 to be login

Edited by aisha.edris1: incorrect spelling

0

i'm doing password varchar(32) but still want the md5 passowrd when i login

Edited by aisha.edris1: incorrect speling

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.