//setting the new product id increamented by 1
    $new_p_id = substr($p_id[0]['product_id'], 2) + 1;
    //product id for new product
    $product_id = "M_" . $new_p_id;
} else {
    $product_id = "M_1001";
}
/* product id is set*/
if (!empty($photo)) {
    //move the uploaded file to the UI Layer img folder
    $result_upload = $uploadFile->upload_file($product_id, 'photo', '../../../img/');
    //photo_name variable saves the image location.
    $photo_name = "img/" . $result_upload;
} else {
    $photo_name = "";
}
/*checking the number of product is more than '5' or not
 * setting the database value for stock column
 */
if ($stock > 5) {
    $status = 1;
} else {
    $status = 0;
}
//discount is set or not
if (!empty($discount)) {
    $result = $manageData->insertMembershipProduct($product_id, $product_name, $description, $price, $discount, $stock, $status, $photo_name);
    header("Location: ../../addMembershipProduct.php?msg=1010");
} else {
    header("Location: ../../addMembershipProduct.php?msg=9874");
}