$insert_id = $result->lastInsertId();
<input name="id" type="hidden" value="<?=$insert_id;?>">
var slides = document.querySelectorAll('.slider-item');
var sliderToggles = document.querySelectorAll('.slider-toggle');
var currentSlide = 0;
if ( slides.length > 0 ) {
var slideInterval = setInterval(nextSlide, 2500);
}
function nextSlide() {
sliderToggles[currentSlide].classList.remove('slider-toggle--active');
slides[currentSlide].classList.remove('active');
currentSlide = (currentSlide+1)%slides.length;
sliderToggles[currentSlide].classList.add('slider-toggle--active');
slides[currentSlide].classList.add('active');
}