<?php
include "opencon.php";
$emails = explode('\r\n', $_POST['list']);
$sql = mysql_query("INSERT INTO emails VALUES('id','email')");
foreach($emails as $email){
$sql .= "('$email'),";
}
$sql = substr($sql,'',-1); //remove last character
//echo "$sql";
mysql_query($sql);
Print "Finished";
?>
and here is my form:
include("opencon.php");
?>
<!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>View DB records</title>
</head>
<body>
<FORM ACTION="loademails.php" METHOD=POST>
One Email Per Line:<BR>
<TEXTAREA NAME="list" COLS=40 ROWS=6></TEXTAREA>
<P><INPUT TYPE=SUBMIT VALUE="submit">
</FORM>
<?php
$q = mysql_query("select * from emails");
if(mysql_num_rows($q)>0){
$count = 1;
while($record = mysql_fetch_array($q)){
echo $count." - ".$record["email"]."<br>";
$count++;
}
}else{
echo "No records in DB";
}
?>
</body>
</html>

New Topic/Question
Reply



MultiQuote






|