Confirmation question before entering into database

Asked

Viewed 234 times

1

I have the following page of Insert:

<?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 entering ask if I’m sure or not,if yes, do the Insert if I don’t direct to the previous page.

Follow the send 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>";

2 answers

2


In the link going to that page you create a js confirm

<a href="pagina.php?acao=inserir" onclick="return confirm('Tem certeza?')">Link</a>
  • Good morning, my button is inside the table and I use the following line, included in the question, when I put the confirm this passing directly in the same way, follows the line including the confirm: echo"<td><center><a href='finish.php? id=". $Row['ID'] ." &usu_id=$v_id_usuario' onclick='Return confirm('Are you sure?')' class='btn btn-info'><span class='glyphicon glyphicon-floppy-saved Aria-Hidden='true'></span></a></center></td>";

  • I got it, thank you.

1

Vitor André’s reply is correct, but you have a quote/quote error in your comment to his reply.

You should add the following onclick attribute:

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

And not

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

You’re breaking the link because you’re not switching between ' and "

Browser other questions tagged

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