0

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

David

index page
<?php
session_start();
ob_start();
include("includes/utilities.php");
include("includes/functions.php");
 $Errors = "";
 $_SESSION['LoggedIn'] = false;
 $_SESSION['UserID'] = "";
 $_SESSION['UserAdmin'] = false;
    if (isset($_POST["Username"])) {
      // var_dump($_POST);   
       SQLUser(); 

    }else{
       loginForm();


    }

    ob_end_flush();
?>          





function call
/* -----------------------------------------------------------------------
 * Function to select a user from the database
 * UserID, UserFullName, UserEmail, UserLastPassword
 *-----------------------------------------------------------------------
*/
function SQLUser(){
$username = (isset($_POST['Username'])) ? $_POST['Username'] : "";
    global $link;
    $userSQL="
        select 
        UserID, UserFullName, UserEmail, UserLastPassword
        from
        `".DBN."`.`users`
        where UserName ='". mysql_real_escape_string(ValidSQLString($_POST['Username'])) . "'
        AND UserPassword = '" . md5($_POST['Password']) . "' AND UserActive = 1 " ; 
        $result = mysqli_query($link,$userSQL);
        echo "<table>";
            if(mysqli_num_rows($result)>0){
                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
            }else{
                    echo "There is a problem with your Usernamr or Password.";
            }// end elseif
        echo "</table>";

}// end function
2
Contributors
2
Replies
8
Views
3 Years
Discussion Span
Last Post by davidjennings
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.