0
Good Afternoon,
I am trying to get a page to delete specific records in a particular table of a Mysql database. In another table, this exclusion and also the amendment work perfectly, but in this one neither presented nor the values of the table when requested, both are practically equal, reserving the appropriate changes for direction in another table.
This is the page that works
<?php
session_start();
if ($_SESSION['larj'] == '7be4c2') {
include 'admin/conecta.php';
include 'topo.php';
$id = addslashes($_GET['id']);
$sql = "SELECT * FROM convidados WHERE con_id = '".$id."'";
$consulta = mysql_query($sql,$db) or die(mysql_error());
$qtd = mysql_num_rows($consulta);
while($item_temp = mysql_fetch_assoc($consulta)){
$convidado_array[] = $item_temp;
}
/*
echo '<pre>';
print_r($convidado_array);
echo '</pre>';
die();
*/
$sql_origem = "SELECT * FROM informacoes WHERE info_tipo = 'or' AND info_atv = '1' ORDER BY info_txt";
$consulta_origem = mysql_query($sql_origem,$db) or die(mysql_error());
$qtd_origem = mysql_num_rows($consulta_origem);
while($item_temp = mysql_fetch_assoc($consulta_origem)){
$origem_array[] = $item_temp;
}
/*
echo '<pre>';
print_r($origem_array);
echo '</pre>';
die();
*/
$sql_vinculo = "SELECT * FROM informacoes WHERE info_tipo = 'vi' AND info_atv = '1' ORDER BY info_txt";
$consulta_vinculo = mysql_query($sql_vinculo,$db) or die(mysql_error());
$qtd_vinculo = mysql_num_rows($consulta_vinculo);
while($item_temp = mysql_fetch_assoc($consulta_vinculo)){
$vinculo_array[] = $item_temp;
}
/*
echo '<pre>';
print_r($vinculo_array);
echo '</pre>';
die();
*/
$sql_tratamento = "SELECT * FROM informacoes WHERE info_tipo = 'tr' AND info_atv = '1' ORDER BY info_txt";
$consulta_tratamento = mysql_query($sql_tratamento,$db) or die(mysql_error());
$qtd_tratamento = mysql_num_rows($consulta_tratamento);
while($item_temp = mysql_fetch_assoc($consulta_tratamento)){
$tratamento_array[] = $item_temp;
}
/*
echo '<pre>';
print_r($tratamento_array);
echo '</pre>';
die();
*/
$sql_eventos = "SELECT * FROM eventos WHERE eve_cli_id = '".$_SESSION['id']."' ORDER BY eve_nome";
$consulta_eventos = mysql_query($sql_eventos,$db) or die(mysql_error());
$qtd_eventos = mysql_num_rows($consulta_eventos);
while($item_temp = mysql_fetch_assoc($consulta_eventos)){
$eventos_array[] = $item_temp;
}
/*
echo '<pre>';
print_r($eventos_array);
echo '</pre>';
die();
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Organização de Eventos - Cerimonialismo - Consultoria</title>
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
body,td,th {
font-family: Verdana, Geneva, sans-serif;
font-size: 10px;
}
a:link {
text-decoration: none;
color: #FFF;
}
a:visited {
text-decoration: none;
color: #FFF;
}
a:hover {
text-decoration: underline;
color: #FF6;
}
a:active {
text-decoration: none;
color: #FFF;
}
.pics {
height: 232px;
width: 232px;
padding: 0;
margin: 0;
}
.pics img {
padding: 15px;
border: 1px solid #ccc;
background-color: #eee;
width: 200px;
height: 200px;
top: 0;
left: 0
}
</style>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
<script src="js/lightbox.js" type="text/javascript"></script>
<script src="clearbox.js" type="text/javascript"></script>
</head>
<body>
<table width="960" align="center" cellpadding="5" cellspacing="10">
<tr>
<td valign="bottom" align="left">
<font face="Verdana" size="4" color="#B0855D">
<strong>Seja bem-vindo(a), <?php echo $_SESSION['nome']; ?></strong>
</font>
</td>
<td align="right" valign="middle">
<!--
<a href="logout.php">
<font color="#666666">
<img src="imagens/sair.png" border="0" width="15" align="absmiddle" /> [ Sair ]
</font>
</a>
-->
</td>
</tr>
<tr>
<td colspan="4" align="center" valign="top">
<table align="center" width="100%" bgcolor="#EFEFEF" style="border:1px solid #CCC" cellpadding="5">
<tr>
<td colspan="6">
<font color="#666666" size="2">
<strong>Minha área de cliente:</strong>
</font>
<br /><br />
</td>
</tr>
<tr>
<td width="16%" align="center" valign="middle">
<a href="convidados.php">
<img src="imagens/convidados_icon.png" border="0" /><br />
<font color="#666666" size="2">
<strong>Convidados</strong>
</font>
</a>
</td>
<td width="17%" align="center" valign="middle">
<a href="confirmacoes.php">
<img src="imagens/confirmacao_icon.png" border="0" /><br />
<font color="#666666" size="2">
<strong>Confirmações</strong>
</font>
</a>
</td>
<td width="17%" align="center" valign="middle">
<a href="relatorios.php">
<img src="admin/imagens/relatorio_icon.png" border="0" /><br />
<font color="#666666" size="2">
<strong>Relatórios</strong>
</font>
</a>
</td>
<td width="17%" align="center" valign="middle">
<a href="logout.php">
<img src="imagens/close_icon.png" border="0" /><br />
<font color="#666666" size="2">
<strong>Sair</strong>
</font>
</a>
</td>
</tr>
</table>
<br /><br /><br />
<font color="#666666" size="3">
<strong>Deseja Excluir os Dados do Convidado: <?php echo $convidado_array[0]['con_nome']; ?>?</strong></font>
<form action="confirma_del_convidado.php" method="post" name="confirma_del_convidado">
<table width="750" cellspacing="2" cellpadding="2" align="center">
<tr>
<td colspan="2">
<a href="javascript:history.go(-1)">
<img src="admin/imagens/voltar_icon.png" border="0" style="padding:5px;" align="absmiddle" /><font color="#555555">Voltar</font>
</a>
</td>
</tr>
<tr>
<td width="40%"> </td>
<td width="60%"><font color="555555">*Campos obrigatórios</font></td>
</tr>
<tr>
<td align="right"><font color="555555"><b>Evento:</b></font></td>
<td>
<?php
for($cont_ev = 0; $cont_ev < $qtd_eventos; $cont_ev++ ){
if($eventos_array[$cont_ev]['eve_id'] == $convidado_array[0]['con_eve_id']){
echo $eventos_array[$cont_ev][eve_nome];
}
}
?>
</td>
</tr>
<tr>
<td align="right"><font color="555555"><b>Nome:</b></font></td>
<td><?php echo $convidado_array[0]['con_nome']; ?></td>
</tr>
<tr>
<td align="right"><font color="555555"><b>Origem:</b></font></td>
<td>
<?php
for($cont_or = 0; $cont_or < $qtd_origem; $cont_or++ ){
if($origem_array[$cont_or]['info_id'] == $convidado_array[0]['con_origem_id']){
echo $origem_array[$cont_or]['info_txt'];
}
}
?>
</td>
</tr>
<tr>
<td align="right"><font color="555555"><b>Vínculo:</b></font></td>
<td>
<?php
for($cont_vi = 0; $cont_vi < $qtd_vinculo; $cont_vi++ ){
if($vinculo_array[$cont_vi]['info_id'] == $convidado_array[0]['con_vinculo_id']){
echo $vinculo_array[$cont_vi]['info_txt'];
}
}
?>
</td>
</tr>
<tr>
<td align="right" valign="top"><font color="555555"><b>Tratamento:</b></font></td>
<td>
<?php
if($convidado_array[0]['con_tratamento_id'] == '0'){
echo $convidado_array[0]['con_tratamento_p'];
} else {
for($cont_tr = 0; $cont_tr < $qtd_tratamento; $cont_tr++ ){
if($tratamento_array[$cont_tr]['info_id'] == $convidado_array[0]['con_tratamento_id']){
echo $tratamento_array[$cont_tr]['info_txt'];
}
}
}
?>
</td>
</tr>
<tr>
<td align="right"><font color="555555"><b>Quantidade de Adultos:</b></font></td>
<td><?php echo $convidado_array[0]['con_qtd_adultos']; ?></td>
</tr>
<tr>
<td align="right"><font color="555555"><b>Quantidade de Crianças:</b></font></td>
<td><?php echo $convidado_array[0]['con_qtd_criancas']; ?></td>
</tr>
<tr>
<td> </td>
<td>
<input type="hidden" name="id" value="<?php echo $convidado_array[0]['con_id']; ?>" />
<input type="submit" name="button" id="button" value="Excluir" />
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<br />
<table width="960" align="center" cellpadding="5" cellspacing="5">
<tr>
<td colspan="2" align="center">
</td>
</tr>
</table>
</body>
</html>
<?php
include 'rodape.php';
} else {
echo "<script> window.location = 'area_cli_login.php'; </script>";
die();
}
?>
this is the page that performs the deletion that works:
<?php
session_start();
if ($_SESSION['larj'] == '7be4c2') {
include 'admin/conecta.php';
$id = addslashes($_POST['id']);
//$atv = addslashes($_POST['atv']);
$sql = "DELETE FROM convidados WHERE con_id = '$id'";
mysql_query($sql,$db) or die(mysql_error());
echo "<script> window.alert('Convidado deletado com sucesso!'); </script>";
echo "<script> window.location = 'javascript:history.go(-2)'; </script>";
} else { // else do if ($_SESSION['7be4c2'] == 1122284) {
echo 'Local Restrito! <br>';
} // fim do else do if ($_SESSION['7be4c2'] == 1122284) {
?>
These next two pages do not work, their only difference and are directed to another table of the same bank:
<?php
session_start();
if ($_SESSION['larj'] == '7be4c2') {
include 'admin/conecta.php';
include 'topo.php';
$id = addslashes($_GET['id']);
$sql = "SELECT * FROM rsvp WHERE rsvp_id = '".$id."' ";
$consulta = mysql_query($sql,$db) or die(mysql_error());
$qtd = mysql_num_rows($consulta);
while($item_temp = mysql_fetch_assoc($consulta)){
$rsvp_array[] = $item_temp;
}
$sql_eventos = "SELECT * FROM eventos WHERE eve_cli_id = '".$_SESSION['id']."' ORDER BY eve_nome";
$consulta_eventos = mysql_query($sql_eventos,$db) or die(mysql_error());
$qtd_eventos = mysql_num_rows($consulta_eventos);
while($item_temp = mysql_fetch_assoc($consulta_eventos)){
$eventos_array[] = $item_temp;
}
/*
echo '<pre>';
print_r($eventos_array);
echo '</pre>';
die();
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Organização de Eventos - Cerimonialismo - Consultoria</title>
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
body,td,th {
font-family: Verdana, Geneva, sans-serif;
font-size: 10px;
}
a:link {
text-decoration: none;
color: #FFF;
}
a:visited {
text-decoration: none;
color: #FFF;
}
a:hover {
text-decoration: underline;
color: #FF6;
}
a:active {
text-decoration: none;
color: #FFF;
}
.pics {
height: 232px;
width: 232px;
padding: 0;
margin: 0;
}
.pics img {
padding: 15px;
border: 1px solid #ccc;
background-color: #eee;
width: 200px;
height: 200px;
top: 0;
left: 0
}
</style>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
<script src="js/lightbox.js" type="text/javascript"></script>
<script src="clearbox.js" type="text/javascript"></script>
</head>
<body>
<table width="960" align="center" cellpadding="5" cellspacing="10">
<tr>
<td width="908" colspan="4" align="center" valign="top"><br />
<font color="#666666" size="3">
<strong>Deseja Excluir os Dados do Convidado: <?php echo $rsvp_array[0]['rsvp_con_nome']; ?>?</strong></font>
<form action="confirma_del_convidado_confirmado.php" method="post" name="confirma_del_convidado">
<table width="750" cellspacing="2" cellpadding="2" align="center">
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="40%"> </td>
<td width="60%"><font color="555555">*Todos os campos são obrigatórios</font></td>
</tr>
<tr>
<td align="right"><font color="555555"><b>Evento:</b></font></td>
<td>
<?php
for($cont_ev = 0; $cont_ev < $qtd_eventos; $cont_ev++ ){
if($eventos_array[$cont_ev]['eve_id'] == $rsvp_array[0]['rsvp_eve_id']){
echo $eventos_array[$cont_ev][eve_nome];
}
}
?>
</td>
</tr>
<tr>
<td align="right"><font color="555555"><b>Nome:</b></font></td>
<td><?php echo $rsvp_array[0]['rsvp_con_nome']; ?></td>
</tr>
<tr>
<td align="right"><font color="555555"><b>Telefone:</b></font></td>
<td>
<td><?php echo $rsvp_array[0]['rsvp_fones']; ?></td>
</tr>
<tr>
<td align="right"><font color="555555"><b>E-mail:</b></font></td>
<td><?php echo $rsvp_array[0]['rsvp_emails']; ?></td>
</tr>
<tr>
<td align="right" valign="top"><font color="555555"><b>Mensagem:</b></font></td>
<td>
<td><?php echo $rsvp_array[0]['rsvp_msg']; ?></td>
</tr>
<tr>
<td align="right"><font color="555555"><b>Quantidade de Adultos:</b></font></td>
<td><?php echo $rsvp_array[0]['rsvp_adultos_conf']; ?></td>
</tr>
<tr>
<td align="right"><font color="555555"><b>Quantidade de Crianças:</b></font></td>
<td><?php echo $rsvp_array[0]['rsvp_criancas_conf']; ?></td>
</tr>
<tr>
<td> </td>
<td>
<input type="hidden" name="id" value="<?php echo $rsvp_array[0]['rsvp_con_id']; ?>" />
<input type="submit" name="button" id="button" value="Excluir" />
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<br />
<table width="960" align="center" cellpadding="5" cellspacing="5">
<tr>
<td colspan="2" align="center">
</td>
</tr>
</table>
</body>
</html>
<?php
} else {
echo 'Local Restrito! <br>';
}
?>
<?php
session_start();
if ($_SESSION['larj'] == '7be4c2') {
include 'admin/conecta.php';
$id = addslashes($_POST['id']);
//$atv = addslashes($_POST['atv']);
$sql = "DELETE FROM rsvp WHERE rsvp_id = '$id'";
mysql_query($sql,$db) or die(mysql_error());
echo "<script> window.alert('Convidado deletado com sucesso!'); </script>";
echo "<script> window.location = 'javascript:history.go(-2)'; </script>";
} else { // else do if ($_SESSION['7be4c2'] == 1122284) {
echo 'Local Restrito! <br>';
} // fim do else do if ($_SESSION['7be4c2'] == 1122284) {
?>
I’ve been trying to figure this out for some time,.
Thank you
Your question is too big for a relatively simple problem, although there is nothing wrong with it from a moderative point of view, it is likely to discourage participants from helping. Perhaps it would be interesting if you tried to restrict yourself to mentioning key code snippets to reduce the scope of the question and make it easier for readers. Just a recommendation.
– Marco Aurélio Deleu
Mysql is deprecated, it’s not about the problem, but somehow you need to urgently review it, and switch to mysqli_ - functions Another problem is
addslashes
, I don’t know where you got this from, but this function has nothing to do with mysql protection, unlike some unsuspecting people teach you wrong on the Internet. mysql protects itself with its own escape functions. As for the problem, it may simply be the fact that the ID is wrong, which will not go wrong, but will also not delete anything.– Bacco