Change this
$check_msg .= "Checked: $value\n";
To
$check_msg .= "Checked: $value\\n";
Because otherwise in javascript it will throw error, saying string literal is not closed.
Also make the alert like following
echo "<script> alert('$check_msg'); </script>;";