Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Use E-mail address instead of username 3.5.x & 4.0

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #61  
Old 12-28-2006, 03:05 PM
  tpaul's Avatar 
tpaul tpaul is offline
 

Newbie
  
Join Date: Dec 2006
Posts: 3
 

Default Re: Use E-mail address instead of username 3.5.x & 4.0

posting removed. see my other posting below.
__________________
~Tyson
Reply With Quote
  #62  
Old 12-28-2006, 05:25 PM
 
stevekem stevekem is offline
 

Senior Member
  
Join Date: Dec 2006
Posts: 111
 

Default Re: Use E-mail address instead of username 3.5.x & 4.0

When you say you set the email field to "unique", what exactly do you mean and how do I do that?


Quote:
Originally Posted by tpaul
I set the email field to "Unique" and added the following code at the top of include/register.php
__________________
X-Cart Gold v4.4.1
Reply With Quote
  #63  
Old 12-29-2006, 02:35 AM
 
just wondering just wondering is offline
 

X-Adept
  
Join Date: Oct 2006
Location: UK
Posts: 471
 

Default Re: Use E-mail address instead of username 3.5.x & 4.0

Quote:
Originally Posted by stevekem
When you say you set the email field to "unique", what exactly do you mean and how do I do that?
Put this into X-Cart's Upgrade or PHPmySQL:
Quote:
Originally Posted by marcgeldon
Code:
ALTER TABLE xcart_customers ADD UNIQUE (usertype, email);

__________________
Location: UK
X-Cart: Gold 4.4.2, Status: Finalizing
Template: Colors
Free Mods: Colour Coded Orders, FAQ Manager
Paid Mods: None... yet.
Server: Linux, Apache: 2.2.15 (Unix), MySQL: 5.0.90-community, PHP: 5.2.13
Reply With Quote
  #64  
Old 12-29-2006, 10:58 AM
  tpaul's Avatar 
tpaul tpaul is offline
 

Newbie
  
Join Date: Dec 2006
Posts: 3
 

Default Re: Use E-mail address instead of username 3.5.x & 4.0

This is how I forced my users to use their email address as their username. It allows the user to make changes to their email address after registering but the username will never change.


Use PHPmySQL to set the email field to "Unique" (in the xcart_customers table)

Add the following code at the top of include/register.php
(this will force all email addresses and usernames to be lowercase)
Quote:
$email = strtolower($email);
$uname = strtolower($email);

Add the following code to the bottom of /check_email_script.tpl
Quote:

{* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx *}
{* COPY E-MAIL AS USERNAME MOD *}
{literal}
<script language="JavaScript1.2">
var uname = "";
function InitSaveVariables(form) {
uname = form.uname.value;
}
function copyemail(form) {
InitSaveVariables(form);
form.uname.value = form.email.value;
}

</script>
{/literal}
{* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx *}

Find the code below in /main/register_account.tpl and
add the below bolded javascript property to code below:
(whenever the user clicks on the "username" or "password" fields (when registering or updating info) the "username" field and "uname" variable get set to equal whatever is in the "email" field. This works pretty well. There is one small catch though, after registering if the user changes their email and clicks in the "password" field(s) the script will change the hidden "uname" variable to equal the new email address and will cause an access denied error upon submit because the script is trying to reset the username as well which is not allowed. If you're lazy you could just use the OnFocusOut javascript control only on the "uname" text fields.)

Quote:


{* Anonymous account *}
<tr>
<td align="right">{$lng.lbl_username}</td>
<td>&nbsp;</td>
<td nowrap="nowrap">
<input type="text" id="uname" name="uname" onFocusOut=javascript:copyemail(this.form); size="32" maxlength="32" value="{if $userinfo.uname}{$userinfo.uname}{else}{$userinfo. login}{/if}" />
{if ($reg_error ne "" and $userinfo.uname eq "" and $userinfo.login eq "") or $reg_error eq "U"}<font class="Star">&lt;&lt;</font>{/if}
</td>
</tr>
<tr>
<td align="right">{$lng.lbl_password}</td>
<td>&nbsp;</td>
<td nowrap="nowrap"><input type="password" name="passwd1" onFocus=javascript:copyemail(this.form); size="32" maxlength="64" value="{$userinfo.passwd1}" />
</td>
</tr>
<tr>
<td align="right">{$lng.lbl_confirm_password}</td>
<td>&nbsp;</td>
<td nowrap="nowrap"><input type="password" name="passwd2" onFocus=javascript:copyemail(this.form); size="32" maxlength="64" value="{$userinfo.passwd2}" />
</td>
</tr>
{* /Anonymous account *}



{* NOT anonymous account *}

<tr>
<td align="right">{$lng.lbl_username}</td>
<td class="Star">*</td>
<td nowrap="nowrap">
{if $userinfo.login ne "" || ($login eq $userinfo.uname && $login ne '')}
<b>{$userinfo.login|default:$userinfo.uname}</b>
<input type="hidden" name="uname" value="{$userinfo.login|default:$userinfo.uname}" />
{else}
<input type="text" id="uname" name="uname" onFocus=javascript:copyemail(this.form); size="32" maxlength="32" value="{if $userinfo.uname}{$userinfo.uname}{else}{$userinfo. login}{/if}" />
{if ($reg_error ne "" and $userinfo.uname eq "" and $userinfo.login eq "") or $reg_error eq "U"}<font class="Star">&lt;&lt;</font>{/if}
{/if}
</td>
</tr>
<tr>
<td align="right">{$lng.lbl_password}</td>
<td><font class="Star">*</font></td>
<td nowrap="nowrap"><input type="password" id="passwd1" name="passwd1" onFocus=javascript:copyemail(this.form); size="32" maxlength="64" value="{$userinfo.passwd1}" />
{if $reg_error ne "" and $userinfo.passwd1 eq ""}<font class="Star">&lt;&lt;</font>{/if}
</td>
</tr>
<tr>
<td align="right">{$lng.lbl_confirm_password}</td>
<td class="Star">*</td>
<td nowrap="nowrap"><input type="password" id="passwd2" name="passwd2" onFocus=javascript:copyemail(this.form); size="32" maxlength="64" value="{$userinfo.passwd2}" />
{if $reg_error ne "" and $userinfo.passwd2 eq ""}<font class="Star">&lt;&lt;</font>{/if}
</td>
</tr>

__________________
~Tyson
Reply With Quote
  #65  
Old 12-31-2006, 01:54 PM
 
Judith Judith is offline
 

Member
  
Join Date: Oct 2006
Posts: 23
 

Default Re: use email rather username

Thank you for that. Worked like a charm!!!
__________________
X-Cart Version 4.1.8
Reply With Quote
  #66  
Old 12-31-2006, 01:55 PM
 
Judith Judith is offline
 

Member
  
Join Date: Oct 2006
Posts: 23
 

Default Re: Use E-mail address instead of username 3.5.x & 4.0

Yes I got it to work.
__________________
X-Cart Version 4.1.8
Reply With Quote
  #67  
Old 01-04-2007, 09:20 AM
 
just wondering just wondering is offline
 

X-Adept
  
Join Date: Oct 2006
Location: UK
Posts: 471
 

Default Re: Use E-mail address instead of username 3.5.x & 4.0

On the Code below (in /main/register_account.tpl) I changed <input type="text" under the {else} to <input type="hidden" so people can't type anything into the Username. Then just put a note at the top saying that the e-mail address will be the Username.

Code:
{* NOT anonymous account *} <tr> <td align="right">{$lng.lbl_username}</td> <td class="Star">*</td> <td nowrap="nowrap"> {if $userinfo.login ne "" || ($login eq $userinfo.uname && $login ne '')} <b>{$userinfo.login|default:$userinfo.uname}</b> <input type="hidden" name="uname" value="{$userinfo.login|default:$userinfo.uname}" /> {else} <input type="text" id="uname" name="uname" onFocus=javascript:copyemail(this.form); size="32" maxlength="32" value="{if $userinfo.uname}{$userinfo.uname}{else}{$userinfo. login}{/if}" /> {if ($reg_error ne "" and $userinfo.uname eq "" and $userinfo.login eq "") or $reg_error eq "U"}<font class="Star">&lt;&lt;</font>{/if} {/if} </td> </tr>
__________________
Location: UK
X-Cart: Gold 4.4.2, Status: Finalizing
Template: Colors
Free Mods: Colour Coded Orders, FAQ Manager
Paid Mods: None... yet.
Server: Linux, Apache: 2.2.15 (Unix), MySQL: 5.0.90-community, PHP: 5.2.13
Reply With Quote
  #68  
Old 02-04-2007, 07:01 PM
  kustomrides's Avatar 
kustomrides kustomrides is offline
 

eXpert
  
Join Date: Apr 2005
Location: Southern California
Posts: 212
 

Default Re: Use E-mail address instead of username 3.5.x & 4.0

#43,
xcell67 ... your mod worked for me on testing 4.1.6. Thanks!

Only addition would be the change the language on lbl_username_n_password , which I did to say "Password (your user name is your email address)"
__________________
x-cart Gold 4.7.4
RedHat Linux 7.2; Pearl 5.20.2; PHP 5.5.26; MySQL 5.6.27, server 5.1.54;
Ruby 2.1.5p273; Python 3.4.2;

Several mods in menu and skin, BSCE shipping-per-product, CDSEO Pro
Reply With Quote
  #69  
Old 02-05-2007, 03:20 AM
 
just wondering just wondering is offline
 

X-Adept
  
Join Date: Oct 2006
Location: UK
Posts: 471
 

Default Re: Use E-mail address instead of username 3.5.x & 4.0

The attached .jpg shows how I have the Registration Help text at the top of the Register Page under 'Create Account'.

Under the red line (I cut the page down so it would fit on the Forums) I have shown how the Contact Information part of the page looks.

I think it's pretty good, any suggestions?

Also, I'm wanting to make it a requirement that Passwords are at least 6 characters long, how do I do this?
Attached Thumbnails
Click image for larger version

Name:	register.jpg
Views:	138
Size:	46.9 KB
ID:	239  
__________________
Location: UK
X-Cart: Gold 4.4.2, Status: Finalizing
Template: Colors
Free Mods: Colour Coded Orders, FAQ Manager
Paid Mods: None... yet.
Server: Linux, Apache: 2.2.15 (Unix), MySQL: 5.0.90-community, PHP: 5.2.13
Reply With Quote
  #70  
Old 03-01-2007, 11:05 AM
 
teddychan teddychan is offline
 

Member
  
Join Date: Mar 2006
Posts: 25
 

Question Re: it is wrong to do in this way!!

i try the #43 method.
however, i found that the logic is wrong.

the method in #43 is simply replace the field username by the user email.

however, it will cause a BIG problem if buyer made an order, then change the email address.

as there is many foreign key "login" in other tables.

it will break all the consistent of the database.

2nd problem is, the login field only have VARCHAR(32)
however, in my 5000 custmers reocrd, there are more than 200 ppl having 32-38 characters in the email.

so, if you simply replace the "login" by using the "email"
buyer will never able to login

I am sorry that I don't know how to do in programming.

But it is suggested to modify to do in this way:
1. mask the login field in the signup, and contact field (may be display as "same as email address")

2.check the email address exist, if exist, display the error message.

3. when new buyer registered, simply assign "1" to the "login" name for the frist buyer.
for the 2nd+ buyer, query the database, get MAX(login)+1

Now, the real login name for the buyer will be "1", "2", "3"

3. change the login form, when ppl type the email address in the login field.
the x-cart backend simply find the REAL username number by using the email address.

in this case, even the buyer change the email address AFTER sign up or ordered something.
there real login name is still NOT change.
what have been changed is only the email.

any comment is welcome.
hope this can help ppl to find the solution.
as i have ask x-cart, they ask for USD200 for this mod....

i am thinking change to ***** for this reason.
__________________
--
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:04 PM.

   

 
X-Cart forums © 2001-2020