Warning: Invalid argument supplied for foreach() in /opt/lampp/htdocs/pbook/inc/login.in.php on line 12

include 'contacts.php';
if($_SERVER['REQUEST_METHOD']=='POST'&& $_POST['submit']=='Login')
    $lname = isset($_POST['lname']) ? trim($_POST['lname']):NULL;
    $lpwd = isset($_POST['lpwd']) ? trim($_POST['lpwd']):NULL;

        $lobj=new DB_Action();
        $l=$lobj->disp("Select * From members where memname= '$lname'and mempass='$lpwd'");
        foreach ($l as $result)
            $aid =$result['memid'];
            $_SESSION['_ENTER'] =1;


You probley have an error in your query.
(assuming $lobj->disp returns false on fail just like mysql_query)

The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable.

So according to above quote from PHP manual,your previous statement is not returning any array/objects.

Most probably error is there in your $lobj->disp("Select * From members where memname= '$lname'and mempass='$lpwd'");

Please show the disp method.Is this running the mysql query and returning arrays???

Member Avatar



print_r($l); exit;

Just before the foreach loop. See what it contains.

In addition, you seem to be using unsanitized input data in your SQL.