【问题标题】:getting the value from PHP variable into html从 PHP 变量中获取值到 html
【发布时间】: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,它可以工作。

标签: php html css web


【解决方案1】:

你的问题可以这样解决:

<?php echo $ppid; ?>

或者

<?= $ppid; ?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-06
    • 1970-01-01
    • 2015-11-01
    • 1970-01-01
    相关资源
    最近更新 更多