Home > Backend Development > PHP Problem > What are the ways to submit a php form?

What are the ways to submit a php form?

(*-*)浩
Release: 2023-02-26 06:28:02
Original
4749 people have browsed it

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.

What are the ways to submit a php form?

##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>
Copy after login
<html>
<head>
  <meta charset="utf-8"/>
  <title>表单已提交</title>
</head>
<body>
<?php

$name = filter($_REQUEST[&#39;name&#39;]);
$email = filter($_REQUEST[&#39;email&#39;]);

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>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template