【发布时间】:2015-12-10 02:42:50
【问题描述】:
我刚接触 PHP。这是我的代码
<html>
<head>
</head>
<body>
<?php
$pidd="123456";
?>
<form name="Form1" id="user-info" action='trackit.php' method="POST">
<input type="hidden" name="pidd" id="pidd" value='<?php=$pidd?>'/>
<input name="Re-Activate My Account" value=" Re-Activate My Account" type="submit" />
</form>
</body>
</html>
我正在尝试访问 pidd 的值并将其写入到 tracking.php 中的文件中
<?php
$redirect = $_POST["pidd"];
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = $redirect;
fwrite($myfile, $txt);
//Redirect the user to their intended location
header('Location: index.html');
?>
但我面临的问题是,它没有将 pidd 的值设为 123456,它只是将其写为字符串,因为它是“?php=$pidd?”。谁能帮我弄清楚我做错了什么。
提前致谢
【问题讨论】:
-
我刚刚发现问题是我的文件是 .html 并且我将其更改为 .php,它可以工作。