How can I avoid the security vulnerability with $_GET[''] and simply write the variable?

Using $_GET directly in your code can expose your application to security vulnerabilities such as SQL injection attacks. To avoid this, you should sanitize and validate any user input before using it in your code. One way to do this is to use filter_input() function in PHP to retrieve and sanitize the input from $_GET.

$name = filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING);
echo $name;