$sql4 = "SELECT userid, userName FROM $user_table WHERE userName= '$userNames'"; $result = $conn->query($sql4); $_SESSION['myUser'] = $result['userid'] ;
I have most code I can find but nothing works
Advertisement
Answer
Assuming these lines of code come immediately after executing an insert of a new user record and you are using PDO. You could try:
$last_id = $conn->lastInsertId(); $_SESSION['myUser'] = $last_id;