I have an input field on the homepage of my site that asks the user to input their email address. When the user clicks the submit button, I would like to redirect them to another page on the site (which will contain a form for name, age, etc.) and pass their email address as a variable in the url. The reason I want to pass the email address as a variable in the url is so that the user doesn't have to re-enter this information.

How would I go about doing this? I have gotten the variable to show in the url but am having trouble retrieving it and saving to a variable.

  • I would have a read here and use $_POST as opposed to passing an email address in the URL and using $_GET.
    – Cai
    Feb 9, 2016 at 23:52

1 Answer 1


The first form:

<form method="post" action="some-url.php">
    <input type="email" placeholder="Email address" value="" name="email">
    <input type="submit" value="Submit" name="email-submit">

Then in some-url.php:

if( isset($_POST['email'] )
    $email = $_POST['email']

The post method would be preferred here since it won't create server log entries that include the user's email address.

You should also do this over SSL since you are collecting "name, age, etc."


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.