corradt Posted May 2, 2008 Share Posted May 2, 2008 Hi at all i have a problem when I refresh my php page from browser, in short, in my db see another same record. How can I resolve this problem? I post you my script. Thanks a lot you are great. <?php include("connect_db.php"); session_start(); if(!empty($_POST['SUBMIT'])){ $totale=$_SESSION['costo']; $nome=$_SESSION['nome_del_cliente']; $cognome=$_SESSION['cognome_del_cliente']; $email=$_SESSION['email']; $via=$_SESSION['via_del_cliente']; $telefono=$_SESSION['telefono_del_cliente']; $_SESSION['nome_sala']=$_POST['nome_della_sala']; $_SESSION['citta_sala']=$_POST['citta_sala']; $_SESSION['via_della_sala']=$_POST['via_della_sala']; $_SESSION['occasione']=$_POST['occasione']; $_SESSION['telefono_sala']=$_POST['telefono_sala']; $_SESSION['data']=$_POST['data']; $_SESSION['ora']=$_POST['ora']; $nome_sala=$_SESSION['nome_sala']; $citta_sala=$_SESSION['citta_sala']; $via_sala=$_SESSION['via_della_sala']; $telefono_sala=$_SESSION['telefono_sala']; $occasione=$_SESSION['occasione']; $ora=$_SESSION['data']; $data=$_SESSION['ora']; $data_ora = mysql_query("SELECT * FROM ordini WHERE ore = '$ora' AND data = '$data'",$connection); $data_ora_exists= mysql_num_rows($data_ora); if($data_ora_exists) {$msg[0] = "record già esistente";} else{$data_ora_ok = 1;} if((count($msg)!= 0)||(!data_ora_ok)){$msg[1]="errore";} else {$details_ok = 1;} if(($data_ora_ok )&& ($details_ok)){ $INSERT = mysql_query("INSERT INTO ordini (email_del_cliente,nome_del_cliente,cognome_del_cliente,via_del_cliente,telefono_del_cliente,ore,data,nome_della_sala,via_della_sala,citta_sala,telefono_sala,intrattenimento_con,totale) VALUES ('$email','$nome','$cognome','$via','$telefono','$ora','$data','$nome_sala','$via_sala','$citta_sala','$telefono_sala','$occasione','$totale')",$connection); } } ?> <html> <body> <form action="<?=$PHP_SELF;?>" method="POST"> <fieldset> <?$msg[1];?> <legend>INSERISCI I DATI RELATIVI LA SALA DI RICEVIMENTO</legend> <p><label for="Nome della sala">Nome della Sala</label><br /> <input type="text" name="nome_della_sala" size="50" /></p> <p><label for="città">Città in cui si trova la sala</label><br /> <input class="formfield" type="text" name="citta_sala" size="50" /></p> <p><label for="via">Via in cui si trova la sala</label><br /> <input class="formfield" type="text" name="via_della_sala" size="50" /></p> <p><label for="telefono_sala">Telefono della sala</label><br /> <input class="formfield" type="text" name="telefono_sala" size="50" /></p> <h3>Altre info importanti</h3> <p><label for="occasione">Scrivere il nome dell'occasione che si intende festeggiare </label><br /> <input class="formfield" value="es: battesimo" type="text" name="occasione" size="50" /></p> <p><label for="ora">A che ora sarà il ricevimento?</label><br /> <input class="formfield" value="15:00" type="text" name="ora" size="5" /></p><?php $msg[0];?> <p><label for="data">In che giorno sarà il ricevimento?</label><br /> <input class="formfield" value="16/09/09" type="text" name="data" size="7" /></p><?php $msg[0];?> <p><input type="submit" name="SUBMIT" value="INVIA" /></p> </fieldset> </form></body> </html> Quote Link to comment Share on other sites More sharing options...
burnside Posted May 2, 2008 Share Posted May 2, 2008 when you refresh your browser, are you hitting F5 ? if so it will add the current stored dada more than once, Quote Link to comment Share on other sites More sharing options...
corradt Posted May 2, 2008 Author Share Posted May 2, 2008 Yes with F5, How Can I resolve this problem Quote Link to comment Share on other sites More sharing options...
burnside Posted May 2, 2008 Share Posted May 2, 2008 your best bet is to re direct then after they have posted the post, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.