I have two PHP pages:
我有两个PHP页面:
giardino.php:
<?php
SESSION_START();
if (isset($_SESSION['utente'])){
?>
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" type="image/x-icon" href="immagini/favicon.ico"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.js"></script>
<link rel="stylesheet" href="css/stile.css"/>
</head>
<body>
<div data-role="page" data-theme="d">
<div data-role="header">
<a href="ambienti.php" data-role="button" data-theme="b" data-icon="arrow-l">Ambienti</a>
<a href="logout.php" data-role="button" data-theme="b" data-icon="delete" >Logout</a>
<h1>Domos - Giardino</h1>
</div><!-- /header -->
<div data-role="content" id="centramento">
<?php
include("configurazione.php");
$id_stanza=1;
$pin=26;
//lettura stato attuale
$comando="select luci from casa where ID_stanza=1";
$query=mysql_query($comando,$connessione);
while($riga=mysql_fetch_array($query)){
$oldstate=$riga['luci'];
}
if($oldstate == 0){
$newstate='accendi luce';
$theme='e';
}
else{
$newstate='spegni luce';
$theme='a';
}
echo "<a href='luce.php' data-role='button' data-theme='$theme' id='radio'>$newstate</a>"
?>
</div><!-- /content -->
<div data-role="footer" data-position="fixed">
<h4>Credits: Silvio Mattiello 5C Informatica 2014/2015</h4>
</div><!-- /footer -->
</div><!-- /page -->
</body>
</html>
<?php
}
else{
header("location:home.php?msg=6");
}
?>
luce.php:
<?php
$id_stanza=1;
$pin=$_GET=26;
$comando = escapeshellcmd("sudo /var/www/domotica/python/luce.py $pin $id_stanza");
$esito = exec($comando);
if ($esito == "allarme attivato"){
header("location:ambienti.php");
exit();
}
else {
header("location:giardino.php");
exit();
}
?>
When I click the button on the first page, I get redirected to the second page.
In the second page, there are some operations and then I get redirected to the first page (or another page, ambienti.php).
But when I am redirected to the first page again, the button on this page (giardino.php) doesn't work. I can't click it. Why?
当我单击第一页上的按钮时,我被重定向到第二页。在第二页中,有一些操作,然后我被重定向到第一页(或另一页,ambienti.php)。但是当我再次被重定向到第一页时,此页面上的按钮(giardino.php)不起作用。我无法点击它。为什么?
1 个解决方案
#1
try to use a require instead of the include, to see if there is any error... It seems to be something with include.
尝试使用require而不是include,看看是否有任何错误...它似乎是包含的内容。
Also, you could try to add 302 http to the header like this and add the full path
此外,您可以尝试像这样添加302 http到标题并添加完整路径
header('Location: http://server_name/ambienti.php', true, 302);
#1
try to use a require instead of the include, to see if there is any error... It seems to be something with include.
尝试使用require而不是include,看看是否有任何错误...它似乎是包含的内容。
Also, you could try to add 302 http to the header like this and add the full path
此外,您可以尝试像这样添加302 http到标题并添加完整路径
header('Location: http://server_name/ambienti.php', true, 302);