Jump to content

Is this correct?


carylson

Recommended Posts

Im not sure if I'm using mysql_fetch_array() and mysql_query() correctly.  I get mysql errors on the following line:

$UserInfo = mysql_fetch_array(mysql_query("SELECT * FROM Users WHERE Username = '". $_REQUEST['frmUsername'] ."' && Password = '". $_REQUEST['frmPassword'] ."'"));

 

Can anybody help?

Thanks!

 

The rest of the code:

<?php

if ($_REQUEST['fcn'] == "login") {

 

if ($_REQUEST['frmUsername'] == "" || $_REQUEST['frmPassword'] == "") {

echo "Invalid login.  Please complete all form data and try again.";

}

else {

$UserInfo = mysql_fetch_array(mysql_query("SELECT * FROM Users WHERE Username = '". $_REQUEST['frmUsername'] ."' && Password = '". $_REQUEST['frmPassword'] ."'"));

 

if ($UserInfo) {

$_SESSION['LoggedIn'] = True;

$_SESSION['ID'] = $UserInfo['ID'];

$_SESSION['Username'] = $UserInfo['Username'];

$_SESSION['AdminLevel'] = $UserInfo['AdminLevel'];

 

echo "Login successful.  Hello, ". $_SESSION['Username'] ."!";

}

else {

echo "Invalid login.  The specified user could not be found.  Please double check your information and try again.";

}

}

}

?>

            ... some html ...

Link to comment
Share on other sites

Change it to this so I can see the error message:

 

         $query = mysql_query("SELECT * FROM Users WHERE Username = '". $_REQUEST['frmUsername'] ."' && Password = '". $_REQUEST['frmPassword'] ."'")
                  or die(mysql_error());
         $UserInfo = mysql_fetch_array($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.