0

我一直在尝试创建一个表单,以 HTML 的形式创建票证以轻松组织事物并查看问题,但是每次我尝试对此进行测试时,它只显示变量,因为$variable这里是我正在使用的脚本为了尝试使这项工作:

function ip(){if (!empty($_SERVER['HTTP_CLIENT_IP'])){$ip=$_SERVER['HTTP_CLIENT_IP'];}else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];}else{$ip=$_SERVER['REMOTE_ADDR'];}return $ip;}
$ip = ip();

$date = date("Y-m-d h:i:s A");
$emailField = $_GET['Email'];
$issue = $_GET['issue'];
$ticketField = $_GET['Ticket'];
$ip = $ip;
$date = $date;
$file = 'admin/logs.php';
$lines = file($file);
$all_lines = implode('',$lines);
$entry = str_replace('<script type="text/javascript" language="JavaScript">endtable()</script><script type="text/javascript" language="JavaScript">copyright()</script>','  <tr>
    <td><div id="logleft"></div></td>
    <td><div id="logmid"><center>$emailField</center></div></td>
    <td><div id="logmid"><center>$ip</center></div></td>
    <td><div id="logmid"><center>$issueField</center></div></td>
    <td><div id="logmid"><center>$ticketField</center></div></td>
    <td><div id="logright"></div></td>
</tr>
<script type="text/javascript" language="JavaScript">endtable()</script><script type="text/javascript" language="JavaScript">copyright()</script>',$all_lines);
$fp = fopen($file,'w'); 
$fw = fwrite($fp,$entry);
fclose($fp);

我已确保表单操作是 GET 而不是 POST,但是没有任何效果,它仍然将变量显示为$variable

4

2 回答 2

0

您是否阅读过有关PHP 中字符串的文档?更改字符串中的引号:' -> " 和 " -> '。或者您可以使用串联

PS 使用file_get_contents读取整个文件

PPS 使用file_put_contents写入整个文件

PPPS 并向我们展示您最初的目的。这段代码看起来你做出了错误的决定。

于 2013-05-17T01:42:53.347 回答
0

试试这个:

function ip(){if (!empty($_SERVER['HTTP_CLIENT_IP'])){$ip=$_SERVER['HTTP_CLIENT_IP'];}else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];}else{$ip=$_SERVER['REMOTE_ADDR'];}return $ip;}
    $ip = ip();

    $date = date("Y-m-d h:i:s A");
    $emailField = $_GET['Email'];
    $issueField = $_GET['issue'];
    $ticketField = $_GET['Ticket'];
    $ip = $ip;
    $date = $date;
    $file = 'admin/logs.php';
    $lines = file($file);
    $all_lines = implode('',$lines);
    $entry = str_replace('<script type="text/javascript" language="JavaScript">endtable()</script><script type="text/javascript" language="JavaScript">copyright()</script>','  <tr>
        <td><div id="logleft"></div></td>
        <td><div id="logmid"><center>'.$emailField.'</center></div></td>
        <td><div id="logmid"><center>'.$ip.'</center></div></td>
        <td><div id="logmid"><center>'.$issueField.'</center></div></td>
        <td><div id="logmid"><center>.'.$ticketField.'</center></div></td>
        <td><div id="logright"></div></td>
    </tr>
    <script type="text/javascript" language="JavaScript">endtable()</script><script type="text/javascript" language="JavaScript">copyright()</script>',$all_lines);
    $fp = fopen($file,'w'); 
    $fw = fwrite($fp,$entry);
    fclose($fp);
于 2013-05-17T01:44:38.663 回答