Save multiple data from textarea PHP and PDO

Asked

Viewed 114 times

0

Good morning,

I have the following script that I need to save all data from the textarea line by line but the script saves only the first line and ignores the rest

receive the data so in textarea

0001:0001:0001:0001
0001:0001:0001:0001
0001:0001:0001:0001

my code

    <?php


if (isset($_POST['acao']) && $_POST['acao'] == 'cadastrar'):

    $lista = strip_tags(filter_input(INPUT_POST, 'lista'));
    list($a, $b, $c, $d) = explode(":", $lista);
    $valor = strip_tags(filter_input(INPUT_POST, 'valor'));
    $data = '21-05-2015';


    $verificar_adm = BD::conn()->prepare("SELECT id FROM `infocc` WHERE cc = ?");
    $verificar_adm->execute(array($user));

    if (!$val->validar()) {

        $erros = $val->getErro();
        echo '<div class="erros">Erro: ' . $erros[0] . '</div>';
    } elseif ($verificar_adm->rowCount() > 0) {

        echo '<br><br> <span align="center" class="help-block note"><i class="icon-warning-sign"></i> Duplicado.</span>';
    } else {

        $dados_cadastrar = array(
            'n' => $n,
            'a' => $a,
            'b' => $b,
            'c' => $c,
            'd' => $d,
            'v' => $v,
            'f' => 'N'
        );

        if ($site->inserir('tabela', $dados_cadastrar)) {

            echo '<br><br> <span align="center" class="help-block note"><i class="icon-warning-sign"></i> Ok</span>';
        } else {

            echo '<br><br> <span align="center" class="help-block note"><i class="icon-warning-sign"></i> Erro Grave, tente novamente.</span>';
        }
    }
endif;
?>

what I must do to save all records ?

  • If this is any framework, and it looks like it is, people won’t know how to help, because you didn’t describe or code some of the functions.

  • Enter the code of inserir()

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.