我正在尝试收集信息。我制作了一个简单的表格,用户在其中写下他的姓名、电子邮件、手机号码和衬衫尺寸。这是我的 php 脚本。
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$number = $_POST['number'];
$size = $_POST['size'];
$fh = fopen("notes.txt", "a");
foreach($_POST as $data => $value){
fwrite($fh, $data);
fwrite($fh, "=");
fwrite($fh, $value);
fwrite($fh, "\r\n");
}
fwrite($fh, "\r\n");
fclose($fh);
echo "Information Submitted";
文本文件放错了信息。
这就是我得到的
name=8008799756 (Suppose to show my name I entered in the form)
email=example@gmail.com
size=Medium
Submit=Submit (number value is not being dispaced)
这是我的 HTML 代码
<form method="post" action="myprocessingscript.php">
<input name="name" placeholder="Name" type="text" class="text" id="name"/>
<input name="email" placeholder="Email" type="text" class="text" id="email" />
<input name="number" placeholder="Mobile Number" type="text" class="text" id="number" />
<input name="size" placeholder="Type your Hoodie Size (Small, Medium or Large)" type="text" class="text" id="size"/>
<input type="Submit" value="Submit" class="button" />
</form>
请让我知道我在这方面犯了什么错误。