Language: PHP
Label: safe
CWE: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.

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}')");
    
}