I'm running a apache2 server on my raspberry pi that's hosting my website. By clicking on a link on my website i'm able to change some values in a textfile.
Now everything works just fine but when the link in my script redirects to the homepage, there seems to be something going wrong.
After redirecting the url isn't 192.168.1.101/index.php , instead it stays 192.168.1.101/scripts/beheerSOD.php?sproeier=1
If I refresh the page the url changes to 192.168.1.101/index.php but the script also executes again
Does someone know what's going on?
Thank you in advance!
HTML link to script (index.php)
<a href="scripts/beheerSOD.php?sproeier=1">Klik op mij!</a>
Script that redirects in the end (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");
}
?>
尝试将标头语句放在脚本的顶部。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.