问题是标头位置发送不同的网址

时间:2017-09-27 14:36:42

标签: php html css

当用户从我的网站删除项目时,一个简单的查询会从数据库中删除附加的记录,并且用户将被带到主页,这将在页面顶部显示一个栏目"项目已删除&# 34;我这样做是因为有一个GET' err'在URL中,所以当错误设置时,它旁边的数字定义应该在页面顶部显示什么警报。

我遇到的问题是,当运行此php脚本时,将显示第4个警报而不是第8个警报。

PHP:

if (mysqli_query($conn, "DELETE FROM projects WHERE id='$del' AND user_id ='$user_id'")) {
        if (mysqli_query($conn, "DELETE FROM refs WHERE project_id='$del' AND user_id ='$user_id'")) {
            setcookie("project_cookie", 0);
            header("Location: index.php/?del=8");
        }
    }

Alerts.php(附在头文件的顶部):

if (isset($_GET['err'])) {
    $err = $_GET['err'];
    $type = "err";

    if ($err == "1") { $alert = "Incorrect Email or Password"; }
    elseif ($err == "2") { $alert = "Email address already exists"; }
    elseif ($err == "3") { $alert = "All fields require values"; }
    elseif ($err == "4") { $alert = "Reference Deleted"; }
    elseif ($err == "5") { $alert = '<a href="http://bradleycousins.co.uk/?auth=signup">' . '<b>' . "Signup"  . '</b>' . '</a>'. " " . "to create and save references"; }
    elseif ($err == "6") { $alert = "You can only have 8 projects"; }
    elseif ($err == "7") { $alert = "Select a project on the left hand side first"; }
    elseif ($err == "8") { $alert = "You have deleted a project"; }

}

我已经查看了很长一段时间,并且不知道为什么第四个警报显示而不是运行PHP删除脚本时的第8个警告。

1 个答案:

答案 0 :(得分:2)

更改,

header("Location: index.php/?err=8");

要,

if (isset($_GET['err'])) {

由于,

if (isset($_GET['del'])) {

<html>
   <head><title></title>
   </head>
   <body>
    <div id="templatemo_header">
        <div id="site_title">
            <p></p>
            <p>
                <a href="#">
                <b>SUPPLY CHAIN STRATEGIC SOURCING</b>
            </a>
            </p>
            <!-- <img src="gifs/hidden_logo.png" alt="hidden logo" width="256" height="116"></img> -->

        </div>
        <p id="intro-text">#WEGSD (We Get Stuff Done) - Supply Chain Team
        </p>
    </div>
<div class="svg">
<svg xmlns:***lots of data
<image
     width="721"
     height="726"
     preserveAspectRatio="none"
     style="image-rendering:optimizeQuality"
     xlink:href="data:image/png;base64****lots of data > </image>

    <a class="fancybox letter-box" title="Invoice Processing" href="invoice_processing.html" data-fancybox-type="iframe" id="invoice-processing"  >

        <image
     y="37.4552"
     x="126.97877"
     id="image55"
     xlink:href="data:image/png;base64******lots of data> </image> </a>
    <a class="fancybox letter-box" title="Payment Release" href="payment_release.html" data-fancybox-type="iframe" id="payment-release"  ><image
     y="18.073133"
     x="367.49765"
     id="image66"
     xlink:href="data:image/png;base64*****lots of data> </image></a>