gpt4 book ai didi

php - 如果 date.php?date=* 未找到或不存在,如何重定向

转载 作者:行者123 更新时间:2023-11-29 11:22:06 25 4
gpt4 key购买 nike

如果没有找到“.php?date=”,有人可以告诉我如何重定向到另一个页面吗?p.s我有明显的问题,我认为这是问题,那么如何解决呢?先谢谢了

<!--====================

左 block .php =======================-->

<ul class="side-block">
<li><a href="#">არქივი</a></li>
<?php
$archive = mysqli_query($db,"SELECT DISTINCT left(date,7) as month FROM blog ORDER BY month DESC , id DESC LIMIT 6");
while($myrow = mysqli_fetch_array($archive)){
printf('<li><a href="date.php?date=%s" class="custom">%s</a></li>',$myrow["month"],$myrow["month"]);
}
?>
</ul>
<!--
===============================================
date.php
===============================================
-->

<?php
include 'bd/blocks/bd.php';
$result = mysqli_query($db,"SELECT keywords,description,author FROM page WHERE page='blog'");
$myrow = mysqli_fetch_array($result);
if(isset($_GET['date']) && !empty($_GET['date'])){
$date = $_GET['date'];
}
elseif (!isset($_GET['date']) && empty($_GET['date'])) {
header("Location: index.php");
exit;
}
else{
header("Location: index.php");
exit;
}
$date= "$date";
$dates=substr($date,0,7);
$result2 = mysqli_query($db,"SELECT date FROM blog WHERE date='$dates' ");
$myrow2=mysqli_fetch_array($result2);
echo mysqli_num_rows($result2);
if(!mysqli_num_rows($result2)){
header("Location: index.php");
exit;
}
$date_title=$date;
$date_begin =$date;
$date++;
$date_end=$date;
$date_begin=$date_begin.'-00';
$date_end=$date_end.'-00';
?>

最佳答案

在向页面输出任何内容后,无法使用 header 进行重定向。使用类似这样的东西来代替 javascript 替代方案:

else {
echo("<script>location.href = 'www.myurlhere.com';</script>");
}

关于php - 如果 date.php?date=* 未找到或不存在,如何重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38746417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com