I have a form that I want to do some server-side validation on. If something needs adjusted, we re-post the form with highlights. If not, it goes to the database. Simple.
This is how I tried to make that system work:
<?php
$page_title="page title";
include('include/header4.inc');
switch ($action){
case "display":
include('./include/pledgeForm.php');
break;
case "check":
include('./include/pledgecheck.php');
break;
case "process":
include('./include/savePledgeInfo.php');
break;
default:
include('./include/pledgeForm.php');
break;
}
include('include/footer4.inc');
?>
When the page loads, it displays the form.
When the form is submitted, it changes $action to "check".
This loads pledgecheck.php, which returns $action as either "process" or "display". In either case, nothing seems to happen. If "display", the page renders header and footer and nothing in between. If "process", no data is saved to the database.
I tried using header() to reload the page but that obviously returns an error.
Why won't this work as written? I think I know (the page only goes through the SWITCH once), but my solution (reload page) isn't a good one either.
Is there a way to make this method work?
Thanks.