View Full Version : php and forms

08-20-2007, 08:14 PM

Sorry if my question is stupid. Is it possible to use values entered in a html form in a php script on the same page? All I know about forms and php is that i can use the POST values on the 2nd page when the form in the first page is submitted.

Another question: Is it possible to setup a php page that is hidden from the user (kind of a redirection page) which processes some values and insert into the database form values entered by the user in a previous page? What I am trying to do is basically have the user fills out a form, when they click submit, they get redirected into another website (but during redirection, the form values will be inserted into the database).

Thank you!

08-20-2007, 08:19 PM
Yes and yes.

To post forms to the same page either leave the action blank, make it the name of the page you're on or use $_SERVER['PHP_SELF'] then at the top of the page you want something like

if(isset($_POST['name of some form field (usually input button']))
//process form here

to redirect use header() (http://www.php.net/manual/en/function.header.php)

header('Location: http://www.example.com');