<?php

include("user.php");
$username=$_SESSION['username'];
$rolemaster_id=$_SESSION['rolemaster_id'];
require("./connect.php");
$eventid=$_REQUEST['eventid'];//eventid
$eventname=$_REQUEST['eventname'];
$eventdate=$_REQUEST['eventdate'];
$eventtime=$_REQUEST['eventtime'];
$type=$_SESSION['title'];

$songsid=$_POST['selectedSongs'];//checkbox id array type

$songsid = implode(",", array_map('intval', $songsid));



$pairNames = $_POST["pairname"];
$commaSeparatedPairNames = implode(",", array_map('mysqli_real_escape_string', $pairNames));
//echo $commaSeparatedPairNames.'jijojoj';
$sql=$con->query("INSERT INTO `addsongsinevent`(`id`,`eventid`, `tilte`, `date`, `time`, `songslistid`,`pairname`,`created_by`,`created_on`,`singer_type`) VALUES (NULL,'$eventid','$eventname','$eventdate','$eventtime','$songsid','$commaSeparatedPairNames','$username','now()','$type')");
//echo "INSERT INTO `addsongsinevent`(`id`, `tilte`, `date`, `time`, `songslistid`) VALUES (NULL,'$eventname','$eventdate','$eventtime','$songsid')";

if ($sql != '') {
       // echo 'ifff';
        echo "<script>alert('Add Songs Successfully')</script>";
        echo "<script>window.location.href='/rythm/homee.php';</script>";
        exit;
    } else {
		//echo "else";
        // handle the case when passwords do not match
        echo "<script>alert('SomethingWent Wrong')</script>";
        echo "<script>window.location.href='/rythm/homee.php';</script>";
        exit;
    }



?>
