Jump to content


Photo

Needing help with an approval processing form


  • Please log in to reply
2 replies to this topic

#1 FeatherStone

FeatherStone
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 26 March 2006 - 08:59 AM

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:
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>";


#2 TEENFRONT

TEENFRONT
  • Members
  • PipPipPip
  • Advanced Member
  • 338 posts

Posted 26 March 2006 - 09:14 AM

iv not looked through it all but maybe try this -

add LIMIT 1 to the end of your queries..
Teenfront.co.uk : Free Teen Chat -  FunkySmileys.co.uk : MSN Smileys -  ArcadeMonkey.co.uk : Free Flash Games
8Baller.co.uk : Free Multiplayer Pool [url=http://8Baller.co.uk]

#3 FeatherStone

FeatherStone
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 26 March 2006 - 12:38 PM

[!--quoteo(post=358487:date=Mar 26 2006, 07:14 PM:name=TEENFRONT)--][div class=\'quotetop\']QUOTE(TEENFRONT @ Mar 26 2006, 07:14 PM) View Post[/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!).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users