Language: PHP
Label: vulnerable
CWE: CWE-352 \u2014 Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.

Code:
 function add_login_info(int $user_id) {
    global $table_prefix;	// table prefix;
    global $conn;			// MySQL connection variable.

    $user_ip = safe_input(get_ipaddr());
    $user_aggent = safe_input($_SERVER['HTTP_USER_AGENT']);
    
    // Insert User information Into Database
    $conn->query("INSERT INTO {$table_prefix}users_login_history (login_users_id, login_ip, login_user_aggent) 
                        VALUES ('{$user_id}', '{$user_ip}', '{$user_aggent}')");
    
}