X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Use E-mail address instead of username 3.5.x & 4.0 (https://forum.x-cart.com/showthread.php?t=8809)

tpaul 12-28-2006 03:05 PM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
posting removed. see my other posting below.

stevekem 12-28-2006 05:25 PM

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


just wondering 12-29-2006 02:35 AM

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);



tpaul 12-29-2006 10:58 AM

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>



Judith 12-31-2006 01:54 PM

Re: use email rather username
 
Thank you for that. Worked like a charm!!!

Judith 12-31-2006 01:55 PM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
Yes I got it to work.

just wondering 01-04-2007 09:20 AM

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>


kustomrides 02-04-2007 07:01 PM

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)"

just wondering 02-05-2007 03:20 AM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
1 Attachment(s)
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?

teddychan 03-01-2007 11:05 AM

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.


All times are GMT -8. The time now is 04:16 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.