Jump to content

Archived

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

OriginalSunny

Login page

Recommended Posts

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!

Share this post


Link to post
Share on other sites
have you tried using SELCT * instead of SELECT admin... ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
are you sure the field names have been spelled correctly etc

Share this post


Link to post
Share on other sites
[!--quoteo(post=366391:date=Apr 19 2006, 01:38 PM:name=OriginalSunny)--][div class=\'quotetop\']QUOTE(OriginalSunny @ Apr 19 2006, 01:38 PM) [snapback]366391[/snapback][/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
[code]
$sql1 = "SELECT admin FROM Employee
WHERE empUsername='".$_POST['empUsername']."'";
[/code]

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

Rob

Share this post


Link to post
Share on other sites
[code]
$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)
[/code]

You didnt get the stuff

Share this post


Link to post
Share on other sites

×

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.