为什么名称和数字在文本文件中放错了位置?

时间:2013-09-30 12:46:56

标签: php forms file

我正在尝试收集信息。我做了一个简单的表格,用户写下他的名字,电子邮件,手机号码和衬衫尺寸。这是我的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>

请让我知道我在这方面犯了什么错误。

0 个答案:

没有答案