Home  >  Article  >  Backend Development  >  How to use $_post function in php to receive data from form in html

How to use $_post function in php to receive data from form in html

WBOY
WBOYOriginal
2016-08-23 09:17:481342browse

I just started learning PHP. I searched a lot online but I can’t use the $_post function to print out the form data
This is the code
HTML part

<code><html>
<head>
<title>php test</title>
<meta charset=utf-8>
<body >
<form action="01.php"method="post"name="form1" >
<table>
<tr>
    <td>fs</td>
    <td><input name="fs"type="text"></td>
    <td><input type="submit"value="提交"></td>
</tr>
</table>
</form>
</body>
</head>
</html>
PHP部分

<?php
$fs=$_post['fs'];
echo $fs;
?>
按提交按钮后只能打印出php的代码</code>

Reply content:

I just started learning PHP. I searched a lot online but I can’t use the $_post function to print out the form data
This is the code
HTML part

<code><html>
<head>
<title>php test</title>
<meta charset=utf-8>
<body >
<form action="01.php"method="post"name="form1" >
<table>
<tr>
    <td>fs</td>
    <td><input name="fs"type="text"></td>
    <td><input type="submit"value="提交"></td>
</tr>
</table>
</form>
</body>
</head>
</html>
PHP部分

<?php
$fs=$_post['fs'];
echo $fs;
?>
按提交按钮后只能打印出php的代码</code>

  • Make sure the formactionpath is correct

  • php’s POSTreceives a writing error. It needs to be capitalized $_POST['fs']. Your lowercase method will be parsed into a variable

$_POST

Capital letters.

PHP variables are case-sensitive. Methods, function names and constants are not distinguished (but they are still required to be consistent). They need to be capitalized as the friend above said, use $_POST[], and you said you can print out php Code, I think it shouldn’t be possible.

Statement:
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