If you really want to separate the pages for form
, database_actions
and display
:
In your php file containing the form:
<form action="database_actions.php"><!-- means form posts to action.php //-->
In database_actions.php
:
# Place code to insert into database and make sure
# no echo or print_f/r commands are issued
# and no spaces or line breaks at the top before `<?php`
# Then place this at the end of
header("Location: http://host/display.php");
In display.php
, you can show whatever output. If you have values to pass, then you may force the movement through sessions.
This kind of approach used to be fine in the old days, MAYBE, but now there are many ways to properly perform the actions you have in mind.. One of them is the Model-View-Controller design pattern.
Of course, you'd be better off using an MVC design pattern.. Here's a sample link:
http://www.tonymarston.net/php-mysql/model-view-controller.html
You can perform a search in google too.. Surely you'll find loads more on MVC patterns..