Forums
This topic is locked
Delete / Update with Multiple Checkbox PHP email?
Posted 29 Mar 2006 23:18:42
1
has voted
29 Mar 2006 23:18:42 Darren Bovis-Coulter posted:
I have read through this script www.phpeasystep.com/mysqlview.php?id=8 a checkbox delete scriptand have managed to get mine working so far. However instead of deleting I am using it to update
some pictures that will be uploaded by the general public, but I want nothing dodgy on the site, so I
have created a page where I display all the images and they have an Activate or Delete Checkbox below
each image. This is all working fine, but now I am stuck what I want to do is send an email to the person
who’s images I reject so they know they need to upload another one.
If you can help me this is my code on the top:
<pre id=code><font face=courier size=2 id=code><img src="../../avatars/<?php echo $row_avatar['avatar']; ?>" width="80" height="80" vspace="5" />
<input name="avemail[]" type="hidden" id="avemail" value="<?php echo $row_email['email']; ?>" />
<input name="activebox[]" type="checkbox" id="activebox[]" value="<? echo $row_avatar['id']; ?>" />Activate
<input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $row_avatar['id']; ?>" />Delete
</font id=code></pre id=code>
As you can see the email address is lifted from a different table, this definitely works as I have displayed
the email under the picture and they are all different.
This is the code at the bottom:
<pre id=code><font face=courier size=2 id=code>
if($delete){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
mail ("".$avemail[$i]."","Avatar Removed","We are sorry to inform you that the AVATAR you uploaded was deemed unsuitable by a member of staff.\r\rOur decision on this matter is final please upload another image ","From: "."\r\n"
$sql = "UPDATE phplog_subs_active SET avatar='', avatar_active='Deleted' WHERE id='$del_id'";
$result = mysql_query($sql);
</font id=code></pre id=code>
For some reason it does not want to take any other email address other than the first one, have
I done something completely daft or is there a more sinister mistake.
Edited by - darren264 on 29 Mar 2006 23:20:32
Replies
Replied 30 Mar 2006 11:34:03
30 Mar 2006 11:34:03 Roddy Dairion replied:
copy and paste accordingly thx.
if($delete)
{
//if not declared anywhere please add this
$checkbox=$_POST['checkbox'];
$avemail=$_POST['avemail'];
//up to here
for($i=0;$i<$count($checkbox);$i++)
{
$del_id = $checkbox[$i];
mail ('".$avemail[$i]."',"Avatar Removed","We are sorry to inform you that the AVATAR you uploaded was deemed unsuitable by a member of staff.\r\rOur decision on this matter is final please upload another image ","From: "."\r\n"
$sql = "UPDATE phplog_subs_active SET avatar='<put ur value here>', avatar_active='Deleted' WHERE id='$del_id'";
$result = mysql_query($sql);
}
<input name="<?='avemail[]'?>" type="hidden" id="avemail" value="<?php echo $row_email['email']; ?>" />
<input name="<?='activebox[]'?>" type="checkbox" id="activebox" value="<? echo $row_avatar['id']; ?>" />Activate
<input name="<?='checkbox[]'?>" type="checkbox" id="checkbox" value="<? echo $row_avatar['id']; ?>" />Delete
Edited by - roders22 on 30 Mar 2006 11:34:46
if($delete)
{
//if not declared anywhere please add this
$checkbox=$_POST['checkbox'];
$avemail=$_POST['avemail'];
//up to here
for($i=0;$i<$count($checkbox);$i++)
{
$del_id = $checkbox[$i];
mail ('".$avemail[$i]."',"Avatar Removed","We are sorry to inform you that the AVATAR you uploaded was deemed unsuitable by a member of staff.\r\rOur decision on this matter is final please upload another image ","From: "."\r\n"
$sql = "UPDATE phplog_subs_active SET avatar='<put ur value here>', avatar_active='Deleted' WHERE id='$del_id'";
$result = mysql_query($sql);
}
<input name="<?='avemail[]'?>" type="hidden" id="avemail" value="<?php echo $row_email['email']; ?>" />
<input name="<?='activebox[]'?>" type="checkbox" id="activebox" value="<? echo $row_avatar['id']; ?>" />Activate
<input name="<?='checkbox[]'?>" type="checkbox" id="checkbox" value="<? echo $row_avatar['id']; ?>" />Delete
Edited by - roders22 on 30 Mar 2006 11:34:46