How can I execute a PHP function in a form action?

后端 未结 7 1059
死守一世寂寞
死守一世寂寞 2020-12-25 11:29

I am trying to run a function from a PHP script in the form action.

My code:



        
相关标签:
7条回答
  • 2020-12-25 12:34
    <?php
    require_once ( 'username.php' );
    
    if (isset($_POST['textfield'])) {
        echo username();
        return;
    }
    
    echo '
    <form name="form1" method="post" action="">
      <p>
        <label>
          <input type="text" name="textfield" id="textfield">
        </label>
      </p>
      <p>
        <label>
          <input type="submit" name="button" id="button" value="Submit">
        </label>
      </p>
    </form>';
    ?>
    

    You need to run the function in the page the form is sent to.

    0 讨论(0)
提交回复
热议问题