PHP form submit

  • Started
  • Last post
  • 2 Responses
  • 8dot3

    When I submit a form I want to refresh the page I am on and display a conformation message.

    I am using action="" to refresh the page.

    Is there a proper way to do this so I can display new content when I refresh the page?

    I am new to PHP, but understand the concepts and syntax. Anyone have any advice for me?

  • mikeyf0

    instead of using action="" use action="myfilename.php" in the form put a hidden element.
    ie
    input type="hidden" name="BeenSubmitted" value="TRUE"

    then at the top of your php
    if($BeenSubmitted=="TRUE"){
    do some stuff;
    }

    or something like that, if this isn't quite right it cos its from my head.

  • mike0

    8dot3, before your page beings do some checking for $_POST so you can see what state the page or form is in. On post, do your error handling, if all checks out then complete your action and set a flag to indicate the new state of the page. then in your page you can optinally display either the form or the confirmation. make sense?

    [page header] -> php code and error handling

    [html page] conditional switch on form and activity status