Salve a tutti, non riesco ad eseguire una semplice operazione come quella di eliminare una voce dal database senza la necessità di caricare, quindi creare una seconda pagina.
Questa è la riga di codice che da modificare:
Per farmi capire meglio, vi linko la pagina di prova che rimuoverò una volta risolto il problema:codice:<td><a href='delete.php?id=".$id."'><img src=\"delete.ico\"></a></td>
Vi allego pure il codice completo, che attualmente si avvale di una seconda pagina:
Quando si aggiunge un ingrediente, ma va bene un qualsiasi nome, il risultato di avvenuto successo o errore appare subito.codice:<html> <title>Ingredienti</title> <form name="Ingredienti" action="ingredienti.php" method="post"> <link rel="stylesheet" href="*****.css" type="text/css"> <body> <h1>Ingredienti</h1> <center> <table border="2"> <?php function CheckName($checkname) { $return=true; $charsok = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "; for($x=0; $x<strlen($checkname); $x++) { $string=substr($checkname, $x, 1); $pos_charsok=strrpos($charsok, $string); if ($pos_charsok===false) { $return=false; return(false); } } return(true); } $nomehost="*****"; $database="*****"; $nomeuser="*****"; $password="*****"; mysql_connect($nomehost,$nomeuser,$password); $replydb=mysql_select_db($database); if ($replydb==false) { print("<h2>Errore nella selezione del database.</h2>"); die("<h3><a href='mailto:*****@*****.***?subject=Errore Selezione Database&body=Ho inserito i dati ma il sito mi ha restituito errore. Grazie!'><font color='springgreen'>Contattami</font></a></h3>"); } $add=$_POST['add']; $add=strtolower($add); $add=ucwords($add); $addk=CheckName($add); if(($addk==true) and ($add!=="")) { //Inserimento dati nel database $sql="INSERT INTO Ingredienti (Ingredienti) VALUES ('$add')"; if (mysql_query($sql)==true) { print("<p>Ingrediente inserito correttamente</p>"); } else { print("<h2>Errore durante l'inserimento nel database.</h2></br>"); print("<h3><a href='mailto:*****@*****.***?subject=Errore Inserimento Database&body=Ho inserito i dati ma il sito mi ha restituito errore. Grazie!'><font color='spinggreen'>Contattami</font></a></h3>"); } } else { print("<p>Inserimento ingrediente errato.</br>Controllare i caratteri.</p>"); } $sql=mysql_query("SELECT * FROM Ingredienti ORDER BY Ingredienti ASC;"); while($cicle=mysql_fetch_array($sql)) { $id=$cicle['ID']; print("<tr> <td><p>".$cicle['Ingredienti']."</p></td> <td><a href='delete.php?id=".$id."'><img src=\"delete.ico\"></a></td> </tr>"); } ?> </table> <h6>Inserire un nuovo ingrediente: <input type='text' name='add'><input type='submit' value='Aggiungi'></h6> </center> </body> </form> </html>
Quello che sto cercando di fare è una singola pagina immediata.
Spero di essermi spiegato.
Grazie in anticipo a tutti.


Rispondi quotando

