PHP is still very good as a web page backend. There are only two methods for PHP form submission, namely GET and POST methods; PHP background uses global variables $_POST;$_GET; to obtain submission data.
##Code: (Recommended learning: PHP video tutorial)
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"/> <title>简单表单提交</title> </head> <body> <form action="welcome.php"> 姓名 <input type="text" name="name"/><br/><br/> 邮箱 <input type="text" name="email"/><br/><br/> <button type="submit" formmethod="GET">GET</button> <button type="submit" formmethod="POST">POST</button> </form> </body> </html>
<html> <head> <meta charset="utf-8"/> <title>表单已提交</title> </head> <body> <?php $name = filter($_REQUEST['name']); $email = filter($_REQUEST['email']); function filter($data){ $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data, ENT_QUOTES); return $data; } ?> <p>你好,<?php echo $name; ?>!您的表单已提交成功!</p> <p>更多信息会发送到您的邮箱:<?php echo $email; ?></p> </body> </html>
The above is the detailed content of What are the ways to submit a php form?. For more information, please follow other related articles on the PHP Chinese website!