Modular Merchant's Remote Membership Validation (RMV) system makes it simple to set up a "members-only" area on your website where your customers can log in to access content that they have purchased. When a customer purchases an eligible product, they will automatically gain access to the protected membership area on your website. Anyone who has not purchased that product won't have access to the website!
There are two ways to communicate with the RMV system, simple mode and XML mode. But, whichever method your script is using to communicate with it, the RMV system will return a list of any error messages it encounters when the customer tries to log in.
How are the error messages formatted?
-
When using the simple mode, the errors are returned as a pipe-delimited string.
-
When using the XML mode, the errors are returned in a section of the XML data.
-
However, whether using simple or XML mode, the mm_membership_validator.php file will also create an array named $errors, which will contain all errors returned by the RMV system. This array can make it easier to evaluate and display any error messages encountered, because no matter which system you're using, the format of the $errors array will always be the same.
Example of displaying error messages
Here is some PHP code that can be used on your RMA login page to display any errors generated during the login process. This same code will work whether you're using the simple mode or XML mode.
code <?php
if(count($errors) > 0) {
echo('<p>The following errors were encountered when attempting to log in:</p>');
echo(implode('<br />', $errors));
}
?>
The code above does the following things:
-
First, it counts the size of the $errors array, to see if it contains anything. If its size is greater than zero, then we know that there are error messages to be displayed.
-
The implode() function will allow us to display each error message in the array, no matter how many there are. Each error message will be separated by "<br />", which is a line break.
The sample code above provides a simple way to determine whether errors were encountered during the customer's attempt to log in to your website's Membership Area, and then display any error messages that were encountered. This sample is meant to be used as a starting point. You're welcome to expand on this concept to make the error reporting in your own RMV script as elaborate as you like.
|