ricaricare stessa pagina dopo un' operazione
-
matti
ciao, si il problema è quello però dove metto la query che elimina?
Io ti consiglio di metterla all'inizio della stessa pagina, in un ciclo IF.
Quando richiami la stessa pagina passi anche un parametro (ad esempio azione=DEL) che ti fa accedere in un ciclo, nel quale puoi inserire la tua query di cancellazione.
es:
<a href="stassaPagina.php?idutente=<? $idutente ?>&azione=DEL">elimina</a>All'inizio della tua pagina poi includi un ciclo IF, che appena carica verifica se è stata richiesta un'azione di cancellazione. In caso affermativo (come da link sopra) il ciclo IF manda in esecuzione la tua query.
Ecco come dovrà essere il ciclo:
if ($azione == "DEL") { // inserisci qui le query di cancellazione... }Prendilo come un consiglio puramente "didattico", perché non so cosa tu ci debba fare ma sotto il profilo della sicurezza non è il massimo...

Ciao,
Melvin -
ho provato cosi ma non va
<?php //Includo i file per la connessione //e per la verifica Utente require_once('connessione.php'); require_once('verificalogin.php'); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Documento senza titolo</title></head> <body> <p><strong>AGGIUNGI NUOVI CONTATTI AL TUO GRUPPO </strong></p> <p><a href="formaggiungicontatti.php?idlista=<?=$_GET[idlista]?>">Aggiungi un nuovo contatto</a></td> </body> </html> <?php if ($azione == "DEL") { $query = "DELETE FROM utente WHERE idutente='$_REQUEST[idutente]'"; $ris=mysql_query($query) or die("Errore nella query:".mysql_error()); $query = "DELETE FROM include WHERE idutente='$_REQUEST[idutente]'"; $ris=mysql_query($query) or die("Errore nella query:".mysql_error()); } if(IsSet($_SESSION['utenteM'])){ $user=$_SESSION['utenteM'][0]; //echo $user; $query1 ="Select * from include where idlista = '$_REQUEST[idlista]'"; $result1 = mysql_query($query1) or die("Errore nella query1:".mysql_error()); $numrows = mysql_num_rows($result1); // echo $numrows; $query1 ="Select * from include where idlista = '$_REQUEST[idlista]'"; $result1 = mysql_query($query1) or die("Errore nella query1:".mysql_error()); for($x=0; $x<$numrows; $x++){ $resrow = mysql_fetch_row($result1); $idutente=$resrow['1']; //echo $idutente; $query2 ="Select * from utente WHERE idutente = '$idutente'"; $ris=mysql_query($query2) or die("Errore nella query2:".mysql_error()); $row = mysql_fetch_assoc($ris); $nome = $row['nome']; //echo "<br>$nome"; ?> <table width="98" border="2"> <tr> <td width="86" height="42"><?php echo $nome; ?></a> <td width="136"><a href="formcontatti.php?idutente=<?=$idutente?>$azione=DEL">elimina</a></td> <?php echo "<br>"; ?></td> </tr> </table> <?php } ?> <?php }// chiusura if else { echo "errore"; } ?> -
-
-
ho fatto cosi ma non va nn cancella nulla:
<?php //Includo i file per la connessione //e per la verifica Utente require_once('connessione.php'); require_once('verificalogin.php'); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Documento senza titolo</title></head> <body> <p><strong>AGGIUNGI NUOVI CONTATTI AL TUO GRUPPO </strong></p> <p><a href="formaggiungicontatti.php?idlista=<?=$_GET[idlista]?>">Aggiungi un nuovo contatto</a></td> </body> </html> <?php if (azione == "DEL") { $query = "DELETE FROM utente WHERE idutente='$_REQUEST[idutente]'"; $ris=mysql_query($query) or die("Errore nella query:".mysql_error()); $query = "DELETE FROM include WHERE idutente='$_REQUEST[idutente]'"; $ris=mysql_query($query) or die("Errore nella query:".mysql_error()); } if(IsSet($_SESSION['utenteM'])){ $user=$_SESSION['utenteM'][0]; //echo $user; $query1 ="Select * from include where idlista = '$_REQUEST[idlista]'"; $result1 = mysql_query($query1) or die("Errore nella query1:".mysql_error()); $numrows = mysql_num_rows($result1); // echo $numrows; $query1 ="Select * from include where idlista = '$_REQUEST[idlista]'"; $result1 = mysql_query($query1) or die("Errore nella query1:".mysql_error()); for($x=0; $x<$numrows; $x++){ $resrow = mysql_fetch_row($result1); $idutente=$resrow['1']; //echo $idutente; $query2 ="Select * from utente WHERE idutente = '$idutente'"; $ris=mysql_query($query2) or die("Errore nella query2:".mysql_error()); $row = mysql_fetch_assoc($ris); $nome = $row['nome']; //echo "<br>$nome"; ?> <table width="98" border="2"> <tr> <td width="86" height="42"><?php echo $nome; ?></a> <td width="136"><a href="formcontatti.php?idutente=<?=$idutente?>azione=DEL">elimina</a></td> <?php echo "<br>"; ?></td> </tr> </table> <?php } ?> <?php }// chiusura if else { echo "errore"; } ?> -
quando clicco su elimina non cancella nulla e sulla sbarra di navigazione compare http://localhost/componente/formcontatti.php?idutente=316azione=DEL
-
-
-
Scusa matti ma ci sono troppi pochi elementi per trovare l'errore...
Dovresti provare almeno a postare l'errore oppure le query (stampale con un echo).
Per quel che ne so potrebbe essere la $_REQUEST che non è supportata dalla versione del tuo interprete PHP...
Se vuoi una mano devi fornire qualche dato più specifico... "non cancella nulla" è troppo generico
-
-
-
-
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi