Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: php and forms

  1. #1
    New Coder
    Join Date
    Aug 2006
    Thanked 0 Times in 0 Posts

    php and forms


    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!

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Bradford, UK
    Thanked 66 Times in 65 Posts
    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

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

    to redirect use header()
    PHP Code:
    header('Location: http://www.example.com'); 


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts