
Originally Posted by
ClickHeRe
$v2 as it's the checked and stripped version of the address
If you add more checking in between $v2 and the actual adding, make sure you use the correct one. Simply echo $v2; will let you see the value before actually doing the insert.
$fielddata = isset( $_POST['myfield'] ) ? $_POST['myfield'] : '';
etc...
Ok when i try it I inser a blank space into the db and it only enters doesnt enter anything after the comma. I am confused I might have put it together wrong i posted it below...
Code:
$message = $fielddata;
if(isset($_POST[s1]))
$array = explode( ',', $fielddata);
foreach ( $array as $v ) {
// remove the whitespace
$v2 = trim( $v );
// You can also add other checks, for example using a regex
// you could check if the address is in the correct format
// insert into DB here
$q1 = "Insert into mail set
email = '" . xss_clean(addslashes($_POST['$v2'])) . "'";
mysql_query($q1);
if(mysql_error())
{
echo mysql_error();
}
else
{
echo "<br><center><font face=verdana size=2 color=red><b>You have sucessfully added the subscribers!";
exit();
}
}
//get the subscribers number
$q1 = "select count(*) from mail where news = 'y' ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
?>
<script>
function CheckNews() {
if(document.f1.message.value=="")
{
window.alert('Enter the new emails!');
document.f1.message.focus();
return false;
}
}
</script>
<form method=post name=f1 onsubmit="return CheckNews();">
<table align=center width=350>
<caption align=center class=BlackLink>You have <?=$a1[0]?> subscribers at your mailing list.<br>
Would you like to add more subscribers?</caption>
<tr>
<td colspan=2 class=TableHead align=center>Add more subscribers!</td>
</tr>
<tr>
<td valign=top>Add Emails to the DB:</td>
<td><textarea name=message rows=10 cols=32></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type=submit name=s1 value=Add! class=sub></td>
</tr>
</table>
</form>
Bookmarks