Hi,
<?php $firstname=$_GET[“firstname”]; $zipcode=$_GET[“zipcode”]; $option=$_GET[“option”];
if ($option==”Instant Medigap Prices”){ header(‘Location: 1’); } elseif ($option==”2”) { header(‘Location: location2test’); } elseif ($option==”3”){ header(‘Location: location3test’); } elseif ($option==”4”){ header(“Location: location4test”); }
Obviously the above wont work in EE with php enabled. How can i change it to allow it to work? I’ve also tried using Mo Variables for aid but still unsure on implementation. i.e. how do i set a var
<?php $option = ?> {get:option} <?php ; ?>
Help & Clarification much appreciated !!
I think the first thing I’d do is get on the latest v2 release. 2.4 is very outdated and the docs, advice, current addons are all based on the assumption you’re running the latest release in whichever version you’re on.
It’s worth it to go ahead and update to at least 2.11.
Assuming that, I’d think Mo Variables would work- it gets you the GET variables. And based on those, do a redirect- or maybe even an html meta refresh if that works better for what you want.
Try to avoid using PHP in templates, and if you find you really need to, it’s easy to just spin up a custom plugin to do the same thing.
Stepping back a bit, if all you’re trying to do here is choose a page based on the URL, you really don’t need PHP for this. It might be worth spending some time looking into the ways that EE has of doing what you want. The basic /template_group/template method is described here:
https://docs.expressionengine.com/v2/urls/url_structure.html
The Pages module also might be useful to you. This allows you to assign an arbitrary URL to any entry:
https://docs.expressionengine.com/v2/add-ons/pages/index.html
Finally, for a more advanced (but very powerful) method, you might look at using template routes:
https://docs.expressionengine.com/v2/urls/template_routes.html
You almost never need to redirect to a page. Set things up so that EE knows which URLs belong to which content, and it’ll just happen.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.