These are not form variables:
if(isset($_POST['professional_courier']))
...
else(isset($_POST['india_post']))
These are values within a different form variable, $_POST['courier']
.
Look at the code that @rpkamp posted to see what you should be checking the value of. You can also var_dump($_POST);
and see exactly what is coming back in from your form.
Your form processing code must be before you draw the form. In particular, your header redirect won’t work after you send anything at all to the browser, and you should get errors.
When your user selects “India post”, your code redirects them to DHL.
In this bit:
if(isset($_POST['professional_courier']))
{
if (!empty($_POST)): header("Location: https://www.tpcindia.com/Tracking2014.aspx?id=".$_POST["trackingid"]."&type=0&service=0");
}
what is the need for the innermost if
clause? You’re inside a check to see if $_POST['courier']
is set, and if it is, then you already know that $_POST
is not empty. I don’t know whether the colon after the if()
is valid or not, I know there’s an alternate syntax and my initial question was going to be why you are mixing the two. But there’s no need at all for that if()
as it will always return true
if the code gets to that point. (Obviously that’s only the case once you’ve sorted out correctly checking for which option was selected - at the moment, as there’s no form variable called professional_courier
, it won’t get there at all.)
There may be other errors in the code, have a stab at fixing the above first and come back if you need more assistance.