0

getting error of undefined id in line 4.how to resolve it?

<?php require_once('includes/Functions.php'); ?>
<?php require_once('includes/DB.php'); ?>
<?php require_once('includes/sessions.php'); ?> 
<?php $searchingParameter = $_GET['id']; ?>
<?php  
  if(isset($_POST["Submit"])){
    $Name = $_POST["commenterName"]; 
    $Email = $_POST["commenterEmail"];
    $Comment = $_POST["commenterThoughts"];

    date_default_timezone_set("Asia/Kolkata");
    $currentTime = time();
    $DateTime = strftime("%B-%d-%Y %H:%M:%S",$currentTime);

    if(empty($Name)||empty($Email)||empty($Comment)){
        $_SESSION["errorMessage"] = "this field can't be empty";
        redirect_to("FullPost.php?id = {$searchingParameter}");
    }
    elseif (strlen($Comment)>500) {
        $_SESSION["errorMessage"] = "Comment length should be smaller than 500 characters";
        redirect_to("FullPost.php?id = {$searchingParameter}");
    }
    else{
         //query to insert comment

           $sql = "INSERT INTO comments(datetime,name,email,comment)";
           $sql.= "VALUES(:dateTime,:Name,:Email,:Comment)";
           $stmt = $connectingdb->prepare($sql);
           $stmt->bindValue(':dateTime',$DateTime);
           $stmt->bindValue(':Name',$Name);
           $stmt->bindValue(':Email',$Email);
           $stmt->bindValue(':Comment',$Comment);
           $Execute = $stmt->execute();


            if($Execute){
                $_SESSION["successMessage"] = " commented successfully.";
                redirect_to("FullPost.php?id ={$searchingParameter} ");
            }
            else{
                $_SESSION["errorMessage"] = "insertion unsuccessful.Try again!!";
                redirect_to("FullPost.php?id ={$searchingParameter} ");
            }



    }
}
?>

I am not able to use $searchParameter in the page and getting the error of undefined id in line 4 why? exact error looks like- Undefined index: id in C:\xampp\htdocs\CMS\FullPost.php on line

0 Answers0