View Single Post
Old 11-18-2012, 02:38 PM   PM User | #20
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,942
Thanks: 7
Thanked 82 Times in 81 Posts
firepages will become famous soon enough
Quote:
Originally Posted by doubledee View Post
But that is almost identical to what I have?!
yes because you simply switched results to error , you need to set either and check both
e.g.
PHP Code:
   if (mysqli_stmt_affected_rows($stmt3)==1){
        
// Insert Succeeded.
        
$_SESSION['resultsCode']['result'] = 'COMMENT_MEMBER_COMMENT_ADDED_2052';

        
// Set values for Success Message.
        
$_SESSION['firstName'] = $firstName;
        
$_SESSION['heading'] = $heading;

        
// Notify Other Subscribed Members
        
notifySubscribersOfNewComment($dbc$articleID$commentID$sessMemberID);

    }else{
        
// Insert Failed.
        
$_SESSION['resultsCode']['error'] = '2';
        
// Set Error Source.
        
$_SESSION['errorPage'] = $_SERVER['SCRIPT_NAME'];

        
// Redirect to Display Outcome.
        
header("Location: " BASE_URL "/account/results.php"); 
    }
// End of VERIFY INSERT. 
& in results.php e.g.
PHP Code:
$errors=array(
 
2=>array('msg'=>'you did this wrong','ID'=>'COMMENT_MEMBER_COMMENT_ADDED','gen_email'=>false),
 
4=>array('msg'=>'you did that wrong','gen_email'=>false),
 
8=>array('msg'=>'you did the other wrong','gen_email'=>true),
 
//etc
)

if(
$_SESSION['resultsCode']){
    if(
$_SESSION['resultsCode']['result']){
         
//do whatever you want to do here
    
}
    if(
$_SESSION['resultsCode']['error']){
         
//its an error you may have other things to do now?
         //check $errors[$_SESSION['resultsCode']['error']]; for what
    
}

as for what is an error... whatever you class as an error but you posted here because you were getting emails for every member action, something I assume you want to avoid... the above is one (simplistic) way of modifying your existing code.
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote