【发布时间】:2015-08-13 16:48:38
【问题描述】:
我正在托管我的网站的树莓派上运行 apache2 服务器。 通过单击我网站上的链接,我可以更改文本文件中的一些值。
现在一切正常,但是当我的脚本中的链接重定向到主页时,似乎出了点问题。
重定向后的url不是192.168.1.101/index.php,而是保持192.168.1.101/scripts/beheerSOD.php?sproeier=1 p>
如果我刷新页面,url 会更改为 192.168.1.101/index.php 但脚本也会再次执行
有人知道发生了什么吗?
提前谢谢你!
HTML 链接到脚本 (index.php)
<a href="scripts/beheerSOD.php?sproeier=1">Klik op mij!</a>
最终重定向的脚本 (scripts/beheerSOD.php)
<?php
if(isset($_GET['sproeier'])){
$sproeier = $_GET['sproeier'];
$SODtxt = file_get_contents('../SOD.txt');
$sproeierIO = $SODtxt{($sproeier-1)};
if($sproeierIO=="0"){
$sproeierIO="1";
}
else{
$sproeierIO="0";
}
$eerst = substr($SODtxt,0,$sproeier-1);
$laatst = substr($SODtxt,$sproeier,strlen($SODtxt));
$SODtxt = $eerst.$sproeierIO.$laatst;
file_put_contents('../SOD.txt', $SODtxt);
header("Location: http://192.168.1.101/index.php");
}
?>
【问题讨论】:
标签: php html apache2 raspberry-pi