从ISSET检查中调用PHP函数

时间:2019-02-21 18:30:49

标签: php function isset

我试图在PHP的ISSET检查中调用函数。

如果我在下面尝试此操作无效:

function UpdateWIP(){
        $link = mysqli_connect(DB_SERVER,DB_USER,DB_PASSWORD,DB_DATABASE);
        $sql = "update wip_attribute_xref wx left join wip_ship_tran w ON w.wip_id = wx.wip_id  set wx.attribute_value = '" . $_POST['flowtag'] . "' where w.wip_ship_tran_id = " . $id . " and wx.attribute_name = 'FLT_TAG'"; 
        $result = mysqli_query($link, $sql) or die(mysql_error());
}

if(isset($_POST['process']) && isset($_GET['url'])){
    if (strlen($_POST['flowtag'])==10){
        UpdateWip();
        header('Location: wip_ship_csr.php?id=' . urlencode($id) . '&cdid=' . urlencode($cdid) . '&sn=' . urlencode($serialnumber));
    }else{
        echo "MISMATCH";
    }
}elseif(isset($_POST['cancel']) && isset($_GET['url'])){
    header('Location: wip_ship_search.php');
}

但是,如果我按照以下方式进行操作,它确实可以工作。为什么?我该如何解决第一种方法?

if(isset($_POST['process']) && isset($_GET['url'])){
    if (strlen($_POST['flowtag'])==10){
        $link = mysqli_connect(DB_SERVER,DB_USER,DB_PASSWORD,DB_DATABASE);
        $sql = "update wip_attribute_xref wx left join wip_ship_tran w ON w.wip_id = wx.wip_id  set wx.attribute_value = '" . $_POST['flowtag'] . "' where w.wip_ship_tran_id = " . $id . " and wx.attribute_name = 'FLT_TAG'"; 
        $result = mysqli_query($link, $sql) or die(mysql_error());
        header('Location: wip_ship_csr.php?id=' . urlencode($id) . '&cdid=' . urlencode($cdid) . '&sn=' . urlencode($serialnumber));
    }else{
        echo "MISMATCH";
    }
}elseif(isset($_POST['cancel']) && isset($_GET['url'])){
    header('Location: wip_ship_search.php');
}

0 个答案:

没有答案