Hi all, I am working on the following code. In the SQL query, I am currently calling all the data from the DB using * and all works fine. I would like to be selective and call the coloumns required i.e UserID, UserFullName, UserEmail, UserLastPassword, but when I do this I get an Undefined index: UserName in C:\wamp\www\david\access\includes\functions.php on line 23 and Undefined index: UserActive in C:\wamp\www\david\access\includes\functions.php on line 24. Which relates to the echo statments.

I am baffled why this doesn't work as the data is called from the DB?

Thanks in advance


index page
 $Errors = "";
 $_SESSION['LoggedIn'] = false;
 $_SESSION['UserID'] = "";
 $_SESSION['UserAdmin'] = false;
    if (isset($_POST["Username"])) {
      // var_dump($_POST);   




function call
/* -----------------------------------------------------------------------
 * Function to select a user from the database
 * UserID, UserFullName, UserEmail, UserLastPassword
function SQLUser(){
$username = (isset($_POST['Username'])) ? $_POST['Username'] : "";
    global $link;
        UserID, UserFullName, UserEmail, UserLastPassword
        where UserName ='". mysql_real_escape_string(ValidSQLString($_POST['Username'])) . "'
        AND UserPassword = '" . md5($_POST['Password']) . "' AND UserActive = 1 " ; 
        $result = mysqli_query($link,$userSQL);
        echo "<table>";
                while ($rowUser = mysqli_fetch_assoc($result)){
                    echo "<tr>";
                    echo "<td width=120>".$rowUser['UserID']."</td>";
                    echo"<td width=220>".$rowUser['UserName']."</td>";
                    echo "<td width=120>".$rowUser['UserActive']."</td>";
                    echo "<td width=120>".$rowUser['UserLastPassword']."</td>";
                    echo "</tr>";
                }// end while
                    echo "There is a problem with your Usernamr or Password.";
            }// end elseif
        echo "</table>";

}// end function

Recommended Answers

UserName and UserActive are not in the select list.

Jump to Post

All 2 Replies

UserName and UserActive are not in the select list.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.