Confirmation question before inserting into the database

1

I have the following insert page:

<?php
include("conn_sys.php");

$setor      = $_POST ["setor"]; 
$fornec     = $_POST ["fornec"];
$desc         = $_POST ["desc"];    
$id_usuario = $_POST ["id_usuario"];
$login      = $_POST ["login"];
$nome       = $_POST ["nome"];
$loja       = $_POST ["loja"];
$nivel      = $_POST ["nivel"];

$incluisol = mysql_query("INSERT INTO solicitacao(sol_id, 
                                                 sol_usu,
                                               sol_setor,
                                                sol_loja,
                                                sol_desc,
                                              sol_fornec,
                                              sol_status)
                               VALUES (               '', 
                                           '$id_usuario', 
                                                '$setor',
                                                 '$loja',
                                                 '$desc',
                                               '$fornec',
                                                    '1')") or die (mysql_error());
                 mysql_query($incluisol,$conn_sys); 

  echo "<script language='javascript'>
                window.location='solicitacoes.php';
        </script>";

?>

What I need, before inserting ask if I'm sure or not, if so, insert if you do not go to the previous page.

Following the push button line:

echo"<td><center><a href='finalizar.php?id=". $row['ID'] ."&usu_id=$v_id_usuario' class='btn btn-info'><span class='glyphicon glyphicon-floppy-saved aria-hidden='true'></span></a></center></td>";
    
asked by anonymous 22.08.2016 / 23:27

2 answers

2

In the link that goes to this page you create a js

<a href="pagina.php?acao=inserir" onclick="return confirm('Tem certeza?')">Link</a>
    
23.08.2016 / 02:07
1

Vitor André's answer is correct, but you have a double-quote error in your comment on his response.

You should add the following onclick attribute:

onclick="return confirm('Tem certeza?')"

And not

onclick='return confirm('Tem certeza?')'

You're breaking the link so you're not switching between 'and'

    
24.08.2016 / 17:05