Jump to content

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resourc


fallenangel1983

Recommended Posts

I have tried some of the online tutorials that talk about user defined variables but i dont know what to do next. can anyone help?

 

<?php

 

// Connect to server and select databse.

 

mysql_connect("localhost","root","") or die("cannot connect");

 

// username and password sent from sign up form

 

$myusername=$_POST['myusername'];

$mypassword=$_POST['mypassword'];

 

$sql="SELECT * FROM users WHERE username='$myusername' and password='$mypassword'";

 

$result=mysql_query($sql);

$count=mysql_num_rows($result);

 

  if($count==1)

  {

    while($row=mysql_fetch_row($result))

    {

      $username = $row[0];

      $password = $row[1];

      $idType  = $row[2];

 

      if($idType==1)

      {

  session_start();

        header("location:Users.html");

      }

      elseif($idType==2)

      {

  session_start();

        header("location:Admin.html");

      }

      elseif($idType==3)

      { 

  session_start();

        header("location:Management.html");

      }

    }

  }

  else

  {

    echo "Wrong Username or Password <br><a href='./LoginPage.php'>Go Back</a>";

  }

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.