I have a registration flow which is working great, name, dob, email, etc. submit, done. I also have a function where the user might come from somewhere else that knows there email address and it might be passed in the url. I would like my reg flow to check the url for the parameter and enter the email in the reg form.
So my basic input code looks like this...
<input type="email" id="your_email" placeholder="enter e-mail adresse">
If I append the url to include &email=123@abc.com, I can successfully pass the email in the url, grab it from the url and enter it into the input box like this...
<?php
$email = $_GET['email'];
?>
<input type="email" id="your_email" placeholder="enter e-mail adresse" value="<?php echo $email;?>
This is great and works. But, if someone arrives at the page and we haven't passed the email, then the email field is populated with the url token.
I'm wondering if anyone has a good idea to get around this please? I thought about saying...
the url contains empty parameter use the normal code with an empty box use the new code with prefilled email
...but I'm not sure how to code HTML inside a script.
I found this code...
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</head>
<body>
<input id="para1" type="email" value="Check URL" />
</body>
<script>
$(document).ready(function () {
$("#para1").on("click", function () {
if (window.location.href.indexOf('?book=') > 0) {
console.log("The URL contains ?book");
}
});
});
</script>
</html>
...but I would need to change the consol.log section to have the input code.
Any help would be great, thanks.