Jump to content


Photo

Login page


  • Please log in to reply
7 replies to this topic

#1 OriginalSunny

OriginalSunny
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 19 April 2006 - 12:38 PM

I have tried create a login page for an administrator so that if the value in admin is 1 it will let the user go through to the next page but it just doesnt work. The code i have used is:

$sql1 = "SELECT admin FROM Employee
WHERE empUsername='$_POST[empUsername]'";
$result1 = mysql_query($sql1)
or die("Couldn't execute query.");
if ($result1 == 1)
{

....(go through to the next page)
}
else
{
(print error message)
}

No matter what i do it just seems to output the error message. I have stored the value 1 for one of the employees and 0 for the other but it still doesnt work. Is it an error in my code?? (I have also tried to put "" around the 1 highlighted in bold). Please help!

#2 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 19 April 2006 - 12:46 PM

have you tried using SELCT * instead of SELECT admin... ?
wisewood: proven fact, I am both wise, and wooden.

#3 OriginalSunny

OriginalSunny
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 19 April 2006 - 01:55 PM

Tried it but still got the same problem. Its either reading in the admin value wrong or i have done something wrong in the coding. I am pretty sure it isnt reading the admin value in wrong however, but i cnat see whats wrong with the coding either.

#4 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 19 April 2006 - 02:01 PM

are you sure the field names have been spelled correctly etc
wisewood: proven fact, I am both wise, and wooden.

#5 Roberto

Roberto
  • Members
  • PipPip
  • Member
  • 16 posts
  • LocationLondon, England

Posted 19 April 2006 - 02:01 PM

[!--quoteo(post=366391:date=Apr 19 2006, 01:38 PM:name=OriginalSunny)--][div class=\'quotetop\']QUOTE(OriginalSunny @ Apr 19 2006, 01:38 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I have tried create a login page for an administrator so that if the value in admin is 1 it will let the user go through to the next page but it just doesnt work. The code i have used is:

$sql1 = "SELECT admin FROM Employee
WHERE empUsername='$_POST[empUsername]'";
$result1 = mysql_query($sql1)
or die("Couldn't execute query.");
if ($result1 == 1)
{

....(go through to the next page)
}
else
{
(print error message)
}

No matter what i do it just seems to output the error message. I have stored the value 1 for one of the employees and 0 for the other but it still doesnt work. Is it an error in my code?? (I have also tried to put "" around the 1 highlighted in bold). Please help!
[/quote]

try
$sql1 = "SELECT admin FROM Employee
WHERE empUsername='".$_POST['empUsername']."'";

that's single quote, double quote .$_POST['empUsername']. double quoute, single quote, double quote.

Rob

*************************************
Mad Mouse Media Web Design
t: (+34) 610 837 558
e: rob@madmousemedia.co.uk
w: www.madmousemedia.co.uk
w: www.madmouseart.com *************************************

#6 OriginalSunny

OriginalSunny
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 19 April 2006 - 09:52 PM

Tried it. Still have no luck.

#7 High_-_Tek

High_-_Tek
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 19 April 2006 - 10:38 PM

$sql1 = "SELECT admin FROM Employee
WHERE empUsername='$_POST[empUsername]'";
$result1 = mysql_query($sql1)
or die("Couldn't execute query.");
$result=mysql_fetch_array($result1);
if ($result['admin'] == 1)

You didnt get the stuff

#8 OriginalSunny

OriginalSunny
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 20 April 2006 - 11:16 AM

It worked. Thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users