mercredi 25 avril 2018

if statement keep redirection me

I am trying to validate link values with database in comment edit page, if statement keep redirecting to error.php

This is what I am trying

// Get valid URL parameters

$sid = $_GET["cid"];
if(isset($_GET["cid"]) && !empty(trim($_GET["cid"] == $sid))){
    $usid = $_SESSION["id"];
    if(isset($_GET['uid']) && !empty(trim($_GET['uid'] == $usid))){
    $sql = "SELECT * FROM comments WHERE cid = ?";
    if($stmt = $mysqli->prepare($sql)){
        $stmt->bind_param("i", $sid);
        $sid = $sid;
        if($stmt->execute()){
            $result = $stmt->get_result();

            if($result->num_rows == 1){
                $row = $result->fetch_array(MYSQLI_ASSOC);
                $name = $row["name"];
                $comment = $row["comment"];
                $title = $row["title"];
            } else{
                // URL doesn't contain valid id. Redirect to error page
                header("location: error.php");
                exit();
            }

        } else{
            echo "Oops! Something went wrong. Please try again later.";
        }
    }
    $stmt->close();
    $mysqli->close();
} else{
    // URL doesn't contain id parameter. Redirect to error page
    header("location: error.php");
    exit();
}
} else{
    // URL doesn't contain id parameter. Redirect to error page
    header("location: error.php");
    exit();
}

Aucun commentaire:

Enregistrer un commentaire