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)

dfawdon 02-13-2006 01:02 PM

Has anyone got this working with 4.017 ?

bigmaggot 03-19-2006 07:16 AM

Seems to work fine on 4.0.17

xcell67 04-14-2006 04:25 PM

Hi,

I'm going to throw in my method for 4.1.0 rc4 in case some couldn't get the others to work.

include/register.php

find

Code:

$fillerror = (empty($uname) || !empty($error) || empty($passwd1) || empty($passwd2) || ($passwd1 != $passwd2));

replace with

Code:

$fillerror = (!empty($error) || empty($passwd1) || empty($passwd2) || ($passwd1 != $passwd2));

By deleting the error check for username, the cart will allow registrations without it.



Find
Code:

if (!@$error && $current_area == "C" && $active_modules["UPS_OnLine_Tools"]) {

Replace with
Code:

if (empty($uname)) $uname = $email;

if (!@$error && $current_area == "C" && $active_modules["UPS_OnLine_Tools"]) {


Since we're not allowing the customer to enter a username, the code above will automatically populate the username field with the email the customer supplies.

Find
Code:

$profile_values['email'] = $email;

Replace with
Code:

$profile_values['email'] = $email;
$profile_values['login'] = $email;


When the customer updates their email, their login will also reflect the change. There's only a slight problem with this. If the customer updates any of their other information, everything is fine. But when they update their email, they will get logged out. I don't know what causes the logout but their email/login still gets changed. What I did for my cart was add a little note "Note: If you change your email address, you will have to re-login for security purposes"

skin1/generate_required_fields_js.tpl

Delete this code to prevent check for uname

Code:

        ["uname", "{$lng.lbl_username|strip|replace:'"':'\"'}"],


skin1/main/register_account.tpl

You'll need to comment out the username fields:

Code:

{* Anonymous account *}
{*
<tr>
<td align="right">Email Address</td>
<td></td>
<td nowrap="nowrap">
<input type="text" name="uname" size="32" maxlength="32" value="{$userinfo.login}" />
</td>
</tr>
*}


Code:

{* NOT anonymous account *}

{*<tr>
<td align="right">Email Address</td>
<td class="Star">*</td>
<td nowrap="nowrap">
{if $userinfo.login ne "" || ($login eq $userinfo.uname && $login ne '')}
{$userinfo.login|default:$userinfo.uname}
{else}
<input type="text" id="uname" name="uname" 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>
*}
<input type="hidden" name="uname" value="{$userinfo.login|default:$userinfo.uname}" />


With the above code, I had to take <input type="hidden" name="uname" value="{$userinfo.login|default:$userinfo.uname}" /> out of the commented out code block because xcart needs it to finish the registration process. You can leave everything else commented out.


All of the above satisfies your needs if you want the customer to use their email as their login. The extra stuff below will add in a second field for them to type their email twice for confirmation:

skin1/main/register_contact_info.tpl or wherever tpl you have your email field in

Add this under the intial email block:

Code:

<TR>
<TD align="right">Retype Email</TD>
<TD><font class=Star>*</font></TD>
<TD nowrap>
<input type="text" id="emailtwo" name="emailtwo" size=32 maxlength=128 value="{$userinfo.email}">
</TD>


skin1/check_email_script.js
Add this:

Code:

            if(document.registerform.emailtwo) {
      if(field.value==document.registerform.emailtwo.value){ }
    else{
        alert("Please reconfirm your email address. It does not match.");
        document.registerform.emailtwo.focus();
        document.registerform.emailtwo.select();
      err = true;
    }
  }


before return !err; at the end of the file

</TR> [/code]

2019 04-28-2006 03:37 PM

xcell67 did you tried for final ver 4.1.0?:roll:
thank you.

Callum 05-06-2006 02:52 PM

Works great in 4.0.18 - thanks!

taltos1 06-29-2006 07:49 AM

Hello all! I need some expert advice. I am trying to get this patch to work.

ALTER TABLE `xcart_customers` ADD UNIQUE (
`email`
);

it does seem to work (i patched through the xcart admin), however, when I try to create a account to test this, and use the same email as an existing account after i press submit I get this error on a blank white page:
Code:

INVALID SQL: 1062 : Duplicate entry 'email@hotmail.com' for key 3
SQL QUERY FAILURE: INSERT INTO xcart_customers ....


Also, there are not duplicate emails in the database.

then it goes to "user created" dialog message but upon checking in the admin the user is not actually created. Any insight about this error.

Any insight please let me know.. :-(

mrkenzie 06-29-2006 07:55 AM

Make sure you don't have the same email in the database for two different accounts.

taltos1 06-29-2006 08:09 AM

Nope, there are no duplicate emails. Any other ideas?

TL408 06-29-2006 08:40 AM

Quote:

Originally Posted by 2019
xcell67 did you tried for final ver 4.1.0?:roll:
thank you.

I would like to know as well. Anyone had a chance to test it yet?

Thanks.

2019 07-05-2006 03:36 AM

any1? :(

marcgeldon 07-14-2006 06:54 AM

Wouldn't it be better to update the database with a unique index on e-mail and usertype?

I mean something like
Code:

ALTER TABLE xcart_customers ADD UNIQUE (usertype, email);

So it would be possible to have a provider, admin and customer account (for testing) on the same e-mail address.

What do you think?

Hope to hear from you soon.


Best wishes,

Marc

qinwubi 08-09-2006 02:53 PM

the code in 4.1.2 is a little different
 
$user_data = func_query_first("SELECT * FROM $sql_tbl[customers] WHERE BINARY login='$username' AND usertype='$usertype' AND status='Y'");

Note there's a BINARY there. I followed boomer's instructions, but it seems it doesn't work. Anyone can give some hint? thanks!

B00MER 08-10-2006 08:53 PM

Re: the code in 4.1.2 is a little different
 
Quote:

Originally Posted by qinwubi
$user_data = func_query_first("SELECT * FROM $sql_tbl[customers] WHERE BINARY login='$username' AND usertype='$usertype' AND status='Y'");

Note there's a BINARY there. I followed boomer's instructions, but it seems it doesn't work. Anyone can give some hint? thanks!


4.1.2 It seems a BINARY condition was added to help compare bytes codes vs charachter as is, the mod should still work up to 4.1.1 as-is, however here is the 4.1.2 code for include/login.php:
Code:

$user_data = func_query_first("SELECT * FROM $sql_tbl[customers] WHERE BINARY (login='$username' OR email='$username')  AND usertype='$usertype' AND status='Y'");

:arrow: http://mysql.com/doc/refman/5.0/en/charset-binary-op.html

nevets1219 08-11-2006 07:43 AM

BINARY only makes it case-sensitive even if the charset isn't case-sensitive right? If we are comparing emails, most of the time we can get away without being case-sensitive (though technically emails are case-sensitive but are not generally enforced). This was in the latest v4.0.19 patch but I didn't include it.

showoff 11-27-2006 02:23 AM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
I did this on my 4.1.3 install as descibed by xcell67 on page4 of this thread and it seemed to work OK, but when testing some other things I registered a new user during checkout, this user´s login wasn´t the e-mail address, it was anonymous-4.
Can anyone reproduce this or did I miss something when performing the mod?
thanks

just wondering 12-01-2006 02:36 AM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
Anyone know anything about the above Post? We'd also like to have this since I don't like the idea of people being able to get Account details of 5 people using the same e-mail address.

Cheers.

stevekem 12-11-2006 10:02 AM

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

Did anyone get this to works correctly on 4.1.3 yet? I would like to implement it into our site if it will work with our version. Thanks!

showoff 12-12-2006 02:07 AM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
I just disabled anonymous orders, everyhing else works fine.

tpaul 12-28-2006 02:40 PM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
I've seen alot of elaborate coding to accomplish what seems to be an easy problem to solve. It's entirely possible that I'm missing some things but this is how I force the username = email address issue.

I set the email field to "Unique" and added the following code at the top of include/register.php

Quote:

$email = strtolower($email);
$uname = $email;


stevekem 12-28-2006 02:47 PM

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

What version of x-cart are using?



Quote:

Originally Posted by tpaul
I've seen alot of elaborate coding to accomplish what seems to be an easy problem to solve. It's entirely possible that I'm missing some things but this is how I force the username = email address issue.

I set the email field to "Unique" and added the following code at the top of include/register.php


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.

Lyndon Smith 03-02-2007 09:57 AM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
Great! Will these mods work on 4.1.3?

just wondering 03-03-2007 08:05 AM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
I found the Code on Post #64 worked fine on my 4.1.x Install (I can't remember exactly what Version I was using at the time) but it should work fine on 4.1.3.

sparker2 03-05-2007 02:37 PM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
Will this work with version 4.1.6

just wondering 03-07-2007 06:38 AM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
It works on my Version 4.1.6. :)

2019 03-12-2007 01:01 PM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
can someone please , post the modded full working version for 4.1.6

thnx

just wondering 03-14-2007 03:05 AM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
2019: Click here.

dsoong 04-03-2007 05:39 PM

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

<!--uname = mail fix-->
{literal}
<SCRIPT type="text/javascript">
<!--
function my_onchange() {
copyemail(document.registerform);
}
if (document.registerform && document.registerform.email)
document.registerform.email.onchange = my_onchange;
-->
</script>
{/literal}



This is my change inspired by #64. Basically the same but I like to keep all changes in one block.

They are inserted after if you are using 4.1.6

Quote:

<tr>
<td align="right">{$lng.lbl_password}</td>
<td><font class="Star">*</font></td>
<td nowrap="nowrap"><input type="password" id="passwd1" name="passwd1" size="32" maxlength="64" value="{$userinfo.passwd1}" />
{if $reg_error ne "" and $userinfo.passwd1 eq ""}<font class="Star">&lt;&lt;</font>{/if}


Next, how do we change the user name in DB?

dsoong 04-03-2007 08:01 PM

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

Originally Posted by tpaul
the script will change the hidden "uname" variable to equal the new email address and will cause an access denied error upon submit



This is quick work around I have

Quote:

$email = strtolower($email);
if (!isset($uname)) $uname = strtolower($email);

I don't know if your code will work the same. I am trying to fix a utf-8 user name problem I having so my code has change quite a bit.

mvolpes 04-10-2007 04:30 AM

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

I implemented the very first mod ..and works a treat ...I am after some nice error handling for the sql insert/update for the register.php....any help??

I like a user to have a user name just a simple option to log in with the email address as was the original post's intention...

Any help would be greatly appreciated

balinor 04-10-2007 04:33 AM

Re: Use E-mail address instead of username 3.5.x & 4.0
 
Hi mvolpes, can you please update your signature with your X-Cart version? Really tough to answer posts when we don't know exactly what version you are using. Thanks :)


All times are GMT -8. The time now is 11:20 PM.

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