Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php and forms

    Hello,

    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
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 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()
    eg.
    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
    •