Miva Madness
MerchantAnswers.com - Got a Question? Get The Answer!

How to Create a Custom Login Script in Miva Merchant 5.0

By: Brennan Heyde Published On: 11/07/2007

One of the best aspects of Miva Merchant 5.0 is that its flexibility to be expanded upon and add new features. This can be done by purchasing a module, or you can even create some cool features yourself.

In this tutorial I am going to show you how to create a custom login script which you can put in your global header or on any Miva page you want.

You can see an example of it here:

As you can see if you are not logged in it will display “Welcome, Guest. Please Login”
If a user enters his username and password and hits enter, it will login them in and also change the text.

As you can see the text changed to “Welcome Back, Brennan” followed by a link to logout.

This feature can be very useful for your customers making it much easier to login and logout from your site.

There are two parts to this code. The first is the Welcome text. Here is the code:

<mvt:if expr="g.Basket:cust_id EQ 0">
Welcome, Guest. Please Login.
<mvt:else>
Welcome Back, &mvt:global:customer:ship_fname; 
<a href="https://www.yourstore.com/mm5/merchant.mvc?
Action=LOGO&Screen=SFNT&Store_Code=YOURSTORECODE" >Logout</a>
</mvt:if>

The g.Basket:cust_id EQ 0 expression is testing to see the if the basket already has a customer id. All this does is test if the customer is already logged in.

If they are not logged in then they will have a cust_id of 0, and it will display the text of “Welcome, Guest. Please Login.”

Now, it the cust_id is not 0, meaning that they are already logged in, then the text being displayed is “Welcome Back, Brennan” followed by a link to logout. Please be sure to change yourstore and yourstorecode above to your own store. Feel free to be creative with this text is you want. You can customize it to display anything you choose.

The next part of our login script is the actual username and password boxes. Here is the code:

<form method="post" action="&mvt:global:secure_sessionurl;" name="form1" >
<input type="hidden" name="Store_Code" value="&mvte:store:code;">
<input type="hidden" name="Screen" value="SFNT">

<label>Username:
<input type="text" size="20" name="Customer_Login" >
</label>
<label>Pass:
<input type="radio" name="Action" value="LOGN"  style="display:none" checked="checked">
<input type="password" size="20" name="Customer_Password">
</label>

<input name="Submit" type="submit" value="Login" >
</form>

This code displays the username and password fields along with the submit button. Again feel free to customize this code as needed to fit your websites style. You can put a table around the username and password boxes to format them for your needs.

That’s all there is to it. This very simple script can greatly increase the usability of your website. You can see the working sample here at Sk8trip’s website.
http://www.sk8trip.com

About the Author: Brennan Heyde is an e-commerce consultant working in San Diego, Ca. He specializes in online marketing and SEO for e-commerce.  Have a struggling e-commerce website? – Contact Brennan today for a site analysis.

 

No votes yet