Integrating aMember Pro with website
From AMember Pro Manual
Contents |
Receipt 1: Adding Login Form to your Website
Add Login Form to HTML Page
Use the following to add a login form anywhere you wish on your site:
<form action="/amember/login.php" method=post> Username: <input type=text name=amember_login size=10><br> Password: <input type=password name=amember_pass size=10><br> <input type=submit value=Login> </form>
Add Login form to a PHP page
As the very first line of your PHP page, add the following:
<?php session_start(); ?>
Then, somewhere on the page, add the following:
<?php
if ($au=$_SESSION['_amember_user']){ // user is logged-in
print "Hello $au[name_f] $au[name_l]!<br>";
print "<a href='/amember/logout.php'>Logout</a>";
} else { // user is not logged-in
print "<form method=post action='/amember/login.php'>
Username: <input type=text name=amember_login size=10><br>
Password: <input type=password name=amember_pass size=10><br>
<input type=submit value='Login'>
</form>";
}
?>
Receipt 2. Add logout link to your Website
Just place the following code somewhere:
<a href="/amember/logout.php">Logout</a>
Receipt 3. Add Member Data to Your Website Page
Add Member Data to aMember-powered pages
It is possible to include data from the members table in the database to any aMember page where user is logged-in For example, you may wish to include a "Welcome John Doe" message at the top of the Membership Info page.
To do this edit the file amember/templates/member.html, adding the following:
Welcome, {$smarty.session._amember_user.name_f} {$smarty.session._amember_user.name_l} !
You can also add additional information. If field is added as a common, it must be used as
{$smarty.session._amember_user.data.phone}
Else, it it is a SQL field, it must be used as :
{$smarty.session._amember_user.phone}
Now visit http://www.yoursite.com/amember/member.php and you will see your addons.
Add Member Information to PHP Pages
If you are using PHP pages on your site, you can also add member information to additional pages. In this case you are using session information to add the data, it will only appear when a member is logged in.
As the very first line of your PHP page, add the following:
<?php session_start(); ?>
Then somewhere on the page, use the following code:
<?php print "Welcome, " . $_SESSION['_amember_user']['name_f'] . " " . $_SESSION['_amember_user']['name_l']; ?>
Again, if field is added as a common, it must be used as
$_SESSION['_amember_user']['data']['phone']
Else, an SQL field, must be used as :
$_SESSION['_amember_user']['phone']