【问题标题】:php doesn't redirect correctlyphp 没有正确重定向
【发布时间】: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


    【解决方案1】:

    尝试将标题语句放在脚本的顶部。

    【讨论】:

    猜你喜欢
    • 2019-09-09
    • 1970-01-01
    • 1970-01-01
    • 2020-02-10
    • 2018-04-14
    • 2021-12-06
    • 2020-05-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多