-2

I'm trying to take the CustomerID from the SQL select statement and then assign it to a $_SESSION variable i can use later on during the session.

MY CODE:

session_start();  
    $Username = $request->getParam('Username');
    $PassW = $request->getParam('PassW');


    $sql = "SELECT CustomerID FROM login WHERE Username= '$Username' AND PassW='$PassW' LIMIT 1";


    try{
        $db = new db();
        $db = $db->connect();

        $stmt = $db->query($sql);
        $stmt->execute();
        $result = $stmt->fetchAll(PDO::FETCH_ASSOC);

        if(count($result) == 1){  
        $_SESSION['Username'] = $Username;
        $_SESSION['CustomerID'] = '****CUSTOMER ID FROM TABLE****';

I'm new to this so any help is appreciated :)

early237
  • 25
  • 1
  • 7

1 Answers1

-1

Sovled it.

$result = $stmt->fetchAll(PDO::FETCH_ASSOC);

needed to be

$result = $stmt->fetchColumn();
early237
  • 25
  • 1
  • 7