Jump to content

PHP Session


sqlfr28

Recommended Posts

I am getting the following error -

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in I:\wamp\www\1\session handling\signin.php on line 7

 

Here is the code-

<?php
extract($_POST);
$cn=mysql_connect('localhost','root','');
mysql_select_db('db1',$cn);
$sql="select user_type from user_dtl where login='$uname' and passwd='$pswd'";
$result=mysql_query($sql,$cn);
$num=mysql_num_rows($result);
if($num>0)
{
$utype=mysql_result($result,0,"user_type");
session_start();
$_SESSION['utype']=$utype;
$_SESSION['uname']=$uname;
if($utype=="A")
{
header('location:admin.php');
}
else if($utype=="G")
{
header('location:home.php');
}
}
else
{
echo "Invalid username/password.<a href='signin.html'>Try again</a> 
}
?>

I have created the database "db1" with a table caled 'user_dtl' with the following fields - 'uid','uname','pswd','user_type' .

is it OK?

Link to comment
Share on other sites

Hi AK,

can you pls rectify the code? I didnt get u properly.

Please..

won't write the code for you, but I will explain further what I am saying.

you state that your field names for the table in use are 'uid','uname','pswd','user_type'.

now in your query,

$sql="select user_type from user_dtl where login='$uname' and passwd='$pswd'";

you are wanting to select data where the field login = $uname and the field passwd = $pswd.

my question to you was where did the "login" and "passwd" fields come from that you have specified in your query?

Link to comment
Share on other sites

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.