How can PHP be used to redirect a user back to an app after clicking an activation link in an email?

When a user clicks an activation link in an email, PHP can be used to redirect them back to the app by setting the "Location" header to the app's URL. This can be achieved by extracting the URL from the activation link and using the header() function in PHP to perform the redirection.

// Extract the URL from the activation link
$activation_link = "http://example.com/activate.php?token=123456";
$app_url = "http://example.com/app.php";

// Redirect the user back to the app
header("Location: $app_url");
exit();