1

I see from another question that it's possible to pass query strings through the URL in EE1 but the question itself and its answer didn't really answer how this is done or help solve my specific question which is, can I pass a query string through the URL and have it fill out a form in EE1? I know you can do this easily with PHP and for this case I'm OK with enabling PHP on this single template. However, my quick test didn't seem to work. I added the following php to the head of the template:

<?php
$first_name = $_GET['first_name'];
$last_name = $_GET['last_name'];
?>

and added the following value parameter to the appropriate input fields:

value="<?php echo $first_name; ?>"
value="<?php echo $last_name; ?>"

I've tried setting PHP to render on input and output and have tried an embedded template for the form as well as placing it in the template but the query string values aren't populating the form fields.

What am I missing here? Is it even possible to get query strings to populate a form in EE1?

3
  • 1
    It seems to work on a test I just did. Just to be sure, what's your URL? Should end in something like: ?first_name=bob&last_name=smith Commented Sep 20, 2013 at 16:08
  • The URL was something like site.com/query_test/?first_name=stuart&last_name=mccoy. Tried it with and without the trailing slash but the form would not populate. Are there any server settings I need to check? Commented Sep 20, 2013 at 17:01
  • Is there anything in your htaccess that would change the url? Commented Sep 20, 2013 at 21:03

1 Answer 1

1

Like @PonderTheWeb I don't see anything wrong with the code you've posted.

Can you confirm that you have PHP on in the template by doing a simple:

<? echo "hello world"; ?>

But much more importantly:

Don't trust user input!

It is not good security practice to simply pass forward your $_GET variables without sanitizing them first.

Fortunately EE makes this pretty easy for you.

// Load EE's Global Input Class
global $IN;

// Pass the EE Global inputs forward to the variable you want to use.
$first_name = $IN->GBL('first_name');
$last_name = $IN->GBL('last_name');

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.