one input, much mails, insert each mail in one register

From: Date: Fri, 25 Sep 2009 04:11:39 +0000
Subject: one input, much mails, insert each mail in one register
Groups: php.db 
Request: Send a blank email to php-db+get-46544@lists.php.net to get a copy of this message
Hi… Thanks to Vinay for your help… works very good... But I can’t validate if one or more of the emails insert in the textarea exist in the table of the DB to not insert it, but yes insert the others mails that not exist in the db. This the cod: <html> <head> <title>Explode trial</title></head> <body> <?php if($_GET['emailreader']) { $username="root"; $password="root"; $database="anda"; $con = mysql_connect("localhost",$username,$password); mysql_select_db("$database", $con); $str = $_GET['emailreader']; $text=$_GET['emailreader']; $spacecount=substr_count($text," "); $emails_exploded=(explode(" ",$str)); $sql = "SELECT * FROM mailing"; $result = mysql_query($sql); $array = mysql_fetch_array($result); $mail = $array['mail']; for ($i=0;$i<=$spacecount;$i++) { if($emails_exploded[$i] != $mail) { echo $emails_exploded[$i]; mysql_query("INSERT INTO mailing (mail) VALUES('$emails_exploded[$i]')") or die(mysql_error()); } } } ?> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="get" name="emailform"> <label for=email>Email</label> <input type="text" name="emailreader" size="200" /> <input type="submit" name="submit" value="Ok !" /> <input type="hidden" name="trigger" value="6" /> <input type="reset" name="cancel" value="Cancel" /> </form> </body> </html> Thanks a lot + _ // Emiliano Boragina _ // Diseño & Comunicación ////////////////// + _ // emiliano.boragina@gmail.com / // 15 40 58 60 02 /////////////////////////// + _

« previous php.db (#46544) next »