Search code examples
formsemailauto-populate

Auto-populating a form from an e-mail link


I'm looking to send out emails containing links to sites that dynamically pre-populate the form fields.

I've been using form field ID's with the link like so

http://website.com/sub/orders.php?Name=Joe&email=fake@faker.com

but it doesn't seem to be working, any ideas?


Solution

  • Since you're doing this in PHP, you'd need something like ...

    if (isset($_GET['email'])) {
        $email = $_GET['email'];
    }
    else {
        $email = '';
    }
    

    ...

    <input type="text" name="email" value="'.$email.'">
    

    Basically, you need to pull in the get variable to prepopulate the form.