Capture User Email Address When Filling Out Form

Everything that comes after the “?” in the URL is what’s known as a “query string.” To use PHP to get the results of a query string, you use $_GET to “get” the value of the variable.

You have two parts, the variable and the value. In the example you gave, “e” is the variable, and what comes after “=” is the value. Like this:

[email protected]

To get that result with PHP, use $_GET like this:

$email = $_GET['e'];

Now, the value contained in the $email variable of your PHP code will contain the value of “e” in the query string.

Be sure to use best practices when getting variables from query strings because they can leave you vulnerable. So make sure that the value is set (using isset()) and sanitize it before using it:

$email = ( isset( $_GET['e'] ) ) ? sanitize_email( $_GET['e'] ) : false;

if ( $email ) {
     // There is an email a value in the "e" query string parameter.
     // You can do whatever you need to do with the email from here.
} else {
     // "e" was empty or did not exist.
}