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

   	<?php 
   if(isset($_POST['gonder'])){ 
   	$botid=$_POST['botid'];
   	$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 sohbetler SET
user_id = ?,
sohbet_sira = ?,
icerik = ?");
$insert = $query->execute(array(
     $botid, $i, $veri
));



	$i++;
}


echo "MESAJLAR EKLENDİ";
   	echo "<style type='text/css'> #form_kutusu{ display:none; } </style>";
   	header('Refresh: 2; url=addmes.php');
   } 
?> </header>
   <body>
      <div id="form_kutusu" />
         <form action="addmes.php" method="POST">
            <p>Bot ID</p>
            <input type="text" name="botid" /><br /> 
            <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>