Submit form to action php file

后端 未结 3 1219
长情又很酷
长情又很酷 2021-01-15 12:09

I have a form where when the user clicks submit, I need a php file to be ran. below is the form and the php file.

3条回答
  •  清歌不尽
    2021-01-15 12:30

    There are a few things wrong with your code.

    You're mixing GET with POST methods. Plus, add values to your inputs and your submit button isn't named, which you're trying to use as a conditional statement for.

    HTML

    
             
             
            
    
    

    PHP

    
    

    Sidenote: You could/should also check against empty values.

    if(isset($_POST['submit']) 
        && !empty($_POST['feature']) 
        && !empty($_POST['feature2']) ) {...}
    

    Footnotes:

    Seeing that you're intending on sending to DB:

    I hope you plan on using mysqli with prepared statements, or PDO with prepared statements.

提交回复
热议问题