我正在尝试创建简单的脚本,其中文本输入数据将通过 php.Html 部分存储在文本文件中,但 php 代码没有显示任何输出,文本文件中也没有写入任何内容。这是我的代码,HTML 部分
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Untitled Document</title>
<LINK REL="Stylesheet" TYPE ="text/css" HREF="info.css">
</head>
<body>
<form style="" method="post" action="personalinfo.php">
<label for="inputname">Name:</label><input id ="inputname" name="iname" input type="text"/>
<br/>
<br/>
<label for=""="inputaddress">Address:</label><input id="inputaddress" name="iaddress" INPUT type="text"/>
<br/>
<br/>
<label for="inputcity">City:</label><input id="inputcity" name="icity" type="text" />
<br/>
<br/>
<label for="inputstate">State:</label><input id="inputstate" name="istate" type="text" />
<br/>
<br/>
<label for="inputzip">Zip Code:</label><input id="inputzip" name="izip" type="text" />
<br/>
<br/>
<input type="submit" name="submit" value="Submit"/>
</form>
</body>
</html>
PHP 代码
<html>
<body>
<?php
if (isset($_POST['iname']))
{
$name=$_POST['iname'];
$address =$_POST['iaddress'];
$city =$_POST['icity']; //the data
$state=$_POST['istate'];
$zip=$_POST['izip'];
$data= "$name|$address|$city|$state|$zip \n";
//open the file and choose the mode
$fh = fopen("pinfo.txt", "a");
fwrite($fh, $data);
fclose($fh);
print '$name';
}
ELSE
{
PRINT"NOThing";
}
?>
</body>
</html>