I need to press a specific button which open a pop up form automatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • havealot
    New Member
    • Jul 2015
    • 6

    I need to press a specific button which open a pop up form automatically

    Hello guys , as said in the title , I'm working on a website as a developer using PHP , what I have now is a pop up review form , which appears when the user press a button, the problem is I'm validating it using PHP and when you press on the submit the validation occurs server side as you know and when it loads the page again you have you will find the form is gone , and you have to press that button again to see the result of the validation
    like: "please enter a valid email..", is there any way I could press that button automatically if isset($_POST) or something ?

    I can provide you with a link of the website if it is allowed , just tell me if you need it.

    I need help :\
    thanks in advance
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    when you press on the submit the validation occurs server side as you know and when it loads the page again you have you will find the form is gone
    when you’re doing the validation and you build up the response, you need to make sure the form is there (in the HTML), visible (via CSS), validated (showing any error messages). therefore PHP needs to fill in the received input data back into the form.

    you also might have a look like frameworks (Symfony, Laravel, Zend) do their form handling.

    Comment

    • Bharat383
      New Member
      • Aug 2011
      • 93

      #3
      you can use the jquery trigger for the same.
      when the page reload with the error, you can check run that code as below :

      Code:
      <?php
      if(isset($_SESSION['error'])
      {
      ?><script type="text/javascript">$( "#button_to_show_popup" ).trigger( "click" );</script><?php
      }
      
      ?>

      Comment

      Working...