FeatherStone Posted March 26, 2006 Share Posted March 26, 2006 Hello all..I am attempting to create an approval form that will approve members, change their database status, and send an email. I am running into two problems and I have no clue what to do further.My first problem is that whomever is the last applicant that I set the status to (yes, no) it sets it the same for all others that are not yet approved.My second is that instead of sending the email to that one person, it sends it to all people in the database.Please forgive me, I'm new to this and have been getting help from various places but still haven't yet been able to get things acting correctly. Thank you in advance for your help, here is the current code:[code]while ($row = mysql_fetch_assoc($result)) { echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\" name=\"approved\" id=\"approved\">"; $first_name = $row['first_name']; $email = $row['email']; $member_id = $row['member_id']; if ($row['approved']==0){ echo "<table width=\"100%\" align=\"center\" cellpadding=\"5\" cellspacing=\"5\">"; echo "<tr bgcolor=\"#f3f3f3\">"; echo "<td width=\"10%\" height=\"27\" bgcolor=\"#cccccc\"><strong>$member_id - $first_name</strong></td>"; echo "<td width=\"10%\" bgcolor=\"#f3f3f3\"><a href=\"mailto:$email\">$email</a><br />"; echo "</td>"; echo "<td width=\"20%\" height=\"27\" bgcolor=\"#f3f3f3\"><strong>Approve?</strong> <input name=\"approve[$member_id]\" type=\"radio\" value=\"yes\" /></td>"; echo "<td width=\"20%\" height=\"27\" bgcolor=\"#f3f3f3\"><strong>Disapprove?</strong><input name=\"approve[$member_id]\" type=\"radio\" value=\"no\" /></td>"; echo "<td width=\"20%\" height=\"27\" bgcolor=\"#f3f3f3\"><strong>Ignore</strong><input name=\"approve[$member_id]\" type=\"radio\" value=\"ignore\" checked=\"checked\" /></td>"; echo "</tr>"; echo "</table>"; echo "<br />"; }//end if row if (!empty($_POST['Submit'])){ $approve = $_POST['approve']; foreach($approve as $key => $yes_or_no){ if($yes_or_no == 'yes'){ if(!isset($query2)) { $query2 = "UPDATE members SET approved= '1' WHERE member_id='".$key."' "; }//end if isset $query2 .= " OR member_id='".$key."' "; $today = date("F j, Y, g:i a"); $ipaddress = $_SERVER['REMOTE_ADDR']; $subject = "Email Subject"; $message = "$first_name, Message. "; $mailheaders = "From: No Reply <noreply@noreply.com>\n"; mail($email, $subject, $message, $mailheaders); echo "<meta http-equiv=\"refresh\" content=\"1\" />"; }else if($yes_or_no == 'no'){ if(!isset($query2)) { $query2 = "UPDATE members SET approved= '-1' WHERE member_id='".$key."' "; } $query2 .= " OR member_id='".$key."' "; }else{ if(!isset($query2)) { $query2 = "UPDATE members SET approved= '0' WHERE member_id='".$key."' "; }//end if isset $query2 .= " OR member_id='".$key."' "; }//end if yes_or_no }//end foreach echo $query2; mysql_query($query2) or die('Could not modify the table because: ' .mysql_error()); }//end post submit }//end while echo "<input type=\"submit\" name=\"Submit\" value=\"Submit\" />"; echo "</form>";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5840-needing-help-with-an-approval-processing-form/ Share on other sites More sharing options...
TEENFRONT Posted March 26, 2006 Share Posted March 26, 2006 iv not looked through it all but maybe try this -add LIMIT 1 to the end of your queries.. Quote Link to comment https://forums.phpfreaks.com/topic/5840-needing-help-with-an-approval-processing-form/#findComment-20804 Share on other sites More sharing options...
FeatherStone Posted March 26, 2006 Author Share Posted March 26, 2006 [!--quoteo(post=358487:date=Mar 26 2006, 07:14 PM:name=TEENFRONT)--][div class=\'quotetop\']QUOTE(TEENFRONT @ Mar 26 2006, 07:14 PM) [snapback]358487[/snapback][/div][div class=\'quotemain\'][!--quotec--]iv not looked through it all but maybe try this -add LIMIT 1 to the end of your queries..[/quote]Thank you very much for your help, I was able to figure out what to change along with adding the LIMIT clause (which I had forgot!). Quote Link to comment https://forums.phpfreaks.com/topic/5840-needing-help-with-an-approval-processing-form/#findComment-20820 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.