<?php
include '../config.php';
?>
<!DOCTYPE html> 
<html>
   <header> 
<title>Bot Mesaj Ekleme</title>

   	<?php 

$query = $db->query("SELECT * FROM jeton_senaryo_sifir ORDER BY id DESC")->fetch(PDO::FETCH_ASSOC);

$senaryo_id = $query['senaryo_id']+1;


   if(isset($_POST['gonder'])){ 
   	$mesajlist=$_POST['mesajlist'];

$parcalanmis = explode("\r\n", $mesajlist);
$i = 1;
foreach ($parcalanmis as $veri) {
	// code...
	echo $veri;
	echo " == EKLENDİ. <br>";


$query = $db->prepare("INSERT INTO jeton_senaryo_sifir SET
senaryo_id = ?,
senaryo_mesaj = ?,
senaryo_sira = ?");
$insert = $query->execute(array(
     $senaryo_id, $veri, $i
));



	$i++;
}


echo "MESAJLAR EKLENDİ";
   	echo "<style type='text/css'> #form_kutusu{ display:none; } </style>";
   	header('Refresh: 2; url=addsnr.php');
   } 
?> </header>
   <body>
      <div id="form_kutusu" />
         <form action="addsnr.php" method="POST">

            <p>Mesajlar</p>
            <textarea id="w3review" name="mesajlist" rows="10" cols="50" placeholder="Alt alta mesajları girin">
</textarea>
            <p><input type="submit" name="gonder" value="Gönder" /></p>
         </form>
      </div>
   </body>
</html>