<?php
  ///////////////////////////////////////////////////
  //2010 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  require_once "../utils/chlang.php";

  $title = $TEXT['book-title2'];

  require_once "../config_a.php";
  require_once "../utils/functions.php";
  require_once "../utils/top_adm.php";

  if($result2['administrator'] == 0) {puterror($result2['skin'],$TEXT['error-loginform2']); require_once "../utils/bottom_adm.php"; exit();}
  if(empty($_POST['book_id'])) {puterror($result2['skin'],$TEXT['error-book5']); require_once "../utils/bottom_adm.php"; exit();}
  if(strlen($_POST['book_id'])>255) {puterror($result2['skin'],$TEXT['error-book6']); require_once "../utils/bottom_adm.php"; exit();}
  $_POST['book_id'] = rep($_POST['book_id']);
  $book_id = $_POST['book_id'];

  // Чистим базу от излишков информации
  $query_clear = mysqli_query($dbcnx,"DELETE FROM tbl_s_book_aut WHERE `book_id`='".$_POST['book_id']."' ");
   if(!$query_clear) {puterror($result2['skin'],$TEXT['error-tbl16']); require_once "../utils/bottom_adm.php"; exit();}

//function disabled by php > 5.5.3
////import_request_variables("gP", "in_");
// before using only ->  while(list($id,$value) = each($in_autor))

  while(list($id2,$value2) = each($_POST))
   {
    if($id2 == "autor")
    {
     while(list($id,$value) = each($value2))
      {
       if($id > 0 && $value == 'on')
       {
        //.. некие действия
        $query = "INSERT INTO tbl_s_book_aut (`s_book_aut` , `autor_id` , `book_id` ) VALUES ( NULL , '$id' , '$book_id')";
        $result = mysqli_query($dbcnx,$query);
         if(!$result) {puterror($result2['skin'],$TEXT['error-tbl16']); require_once "../utils/bottom_adm.php"; exit();}
     }
   }
  }
 }
    echo "<html><head>
          <meta HTTP-EQUIV='Refresh' CONTENT='0; URL=add_izd.php?book_id=".$book_id."' />
          </head></html>";

  require_once "../utils/bottom_adm.php";
?>