Author Topic: [SOLVED] ajax registration  (Read 58403 times)

Pyno

  • Jr. Member
  • **
  • Posts: 52
Re: [SOLVED] ajax registration
« Reply #45 on: December 15, 2010, 16:11:14 pm »
First big thanks to peetree21 for a shared hack.

Well, I think I fixed most problems.


So  ;)

* fixed: not showing name and password in the form to change user data.
* fixed: in form to change user data has also investigated the email and username.
* fixed: length of fields and characters for a username and email can now be adjusted as other fields in the admin panel.
(Tests were made with VirtueMart 1.1.4 and IE6, IE7, IE8 and Mozilla)


According to recent tests that have been made, everything works as it should be.

Noted problems: not detected




Here's what should be done:


1. FILE: /administrator/components/com_virtuemart/html/checkout_register_form.php

CHANGE THESE LINEs
Code: [Select]
$missing = vmGet( $_REQUEST, "missing", "" );

if (!empty( $missing )) {
echo "<script type=\"text/javascript\">alert('".$VM_LANG->_('CONTACT_FORM_NC',false)."'); </script>\n";
}

AND REPLACE IT WITH THIS CODE:
Code: [Select]
$missing = vmGet( $_REQUEST, "missing", "" );

?>

<script language="javascript" type="text/javascript">



function getUsername(){
var form = document.adminForm;
var uname = form.username.value;

if( !$('username_ticker') )
$('username_input').innerHTML = $('username_input').innerHTML + "<div id=\"username_ticker\" style=\"padding-top:10px;\"></div>";

$('username_field').value = uname;

if( form.username.value.length < 3 ) {
$('username_ticker').innerHTML = '<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">Username : This input value is not valid.</span>';
} else {
$('username_ticker').innerHTML = "<img src=\"<?php echo JURI::base()."images/wait.gif";?>\">&nbsp;Checking";
var url = 'index.php?option=com_virtuemart&tasked=chkuserinfo&format=raw&what=uname';
url = url + '&uname=' + form.username.value;

new Ajax(url, {
method: 'get',
onComplete: function(x){
if(x == 1) {
$('username_ticker').innerHTML = '<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">This username is already registered.</span>';
} else {
$('username_ticker').innerHTML = '<span style="border:1px none transparent;color:green;padding:5px 5px 5px 5px;">The username \''+ $('username_field').value +'\' is free for registration: you can proceed.</span>';
}
}
}).request();

}
}


function getEmail(){

var form = document.adminForm;
var eadd = form.email.value;

if( !$('email_ticker') )
$('email_input').innerHTML = $('email_input').innerHTML + "<div id=\"email_ticker\" style=\"padding-top:10px;\"></div>";

$('email_field').value = eadd;

if( !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value))) {
$('email_ticker').setHTML('<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">Email : This input value is not valid.</span>');
} else {
$('email_ticker').setHTML("<img src=\"<?php echo JURI::base()."images/wait.gif";?>\">&nbsp;Checking");
var url = 'index.php?option=com_virtuemart&tasked=chkuserinfo&format=raw&what=email';
url = url + '&email=' + form.email.value;

new Ajax(url, {
method: 'get',
onComplete: function(x){
if(x == 1) {
$('email_ticker').setHTML('<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">This email is already registered.</span>');
} else {
$('email_ticker').setHTML('<span style="border:1px none transparent;color:green;padding:5px 5px 5px 5px;">The email \''+ $('email_field').value +'\' is free for registration: you can proceed.</span>');
}
}
}).request();

}
}



</script>
<?php

if (!empty( $missing )) {
echo "<script type=\"text/javascript\">alert('".$VM_LANG->_('CONTACT_FORM_NC',false)."'); </script>\n";
}



2. FILE: /administrator/components/com_virtuemart/classes/ps_userfield.php

AFTER THESE LINES
Code: [Select]
case 'password':
case 'password2':
echo '<input type="password" id="'.$field->name.'_field" name="'.$field->name.'" size="30" class="inputbox" />'."\n";
    break;

ADD THE CODES BELOW:
Code: [Select]
case 'email':
$maxlength = $field->maxlength ? 'maxlength="'.$field->maxlength.'"' : '';
echo '<input type="text" id="'.$field->name.'_field" name="'.$field->name.'" size="'.$field->size.'" onchange="getEmail();" value="'. ($db->sf($field->name, true, false)?$db->sf($field->name, true, false):'') .'" class="inputbox" '.$maxlength . $readonly . ' />'."\n";
  break;
case 'username':
$maxlength = $field->maxlength ? 'maxlength="'.$field->maxlength.'"' : '';
echo '<input type="text" id="'.$field->name.'_field" name="'.$field->name.'" size="'.$field->size.'" onchange="getUsername();" value="'. ($db->sf($field->name, true, false)?$db->sf($field->name, true, false):'') .'" class="inputbox" '.$maxlength . $readonly . ' />'."\n";
  break;


3. In the same file (ps_userfield.php)

AFTER THESE LINES
Code: [Select]
      /**
      * This is the most important part of this file
      * Here we print the field & its contents!
      */

ADD THE CODES BELOW:
Code: [Select]
             ?>
             
             <script language="javascript" type="text/javascript">



function getUsername(){
var form = document.adminForm;
var uname = form.username.value;

if( !$('username_ticker') )
$('username_input').innerHTML = $('username_input').innerHTML + "<div id=\"username_ticker\" style=\"padding-top:10px;\"></div>";

$('username_field').value = uname;

if( form.username.value.length < 3 ) {
$('username_ticker').innerHTML = '<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">Username : This input value is not valid.</span>';
} else {
$('username_ticker').innerHTML = "<img src=\"<?php echo JURI::base()."images/wait.gif";?>\">&nbsp;Checking";
var url = 'index.php?option=com_virtuemart&tasked=chkuserinfo&format=raw&what=uname';
url = url + '&uname=' + form.username.value;

new Ajax(url, {
method: 'get',
onComplete: function(x){
if(x == 1) {
$('username_ticker').innerHTML = '<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">This username is already registered.</span>';
} else {
$('username_ticker').innerHTML = '<span style="border:1px none transparent;color:green;padding:5px 5px 5px 5px;">The username \''+ $('username_field').value +'\' is free for registration: you can proceed.</span>';
}
}
}).request();

}
}


function getEmail(){

var form = document.adminForm;
var eadd = form.email.value;

if( !$('email_ticker') )
$('email_input').innerHTML = $('email_input').innerHTML + "<div id=\"email_ticker\" style=\"padding-top:10px;\"></div>";

$('email_field').value = eadd;

if( !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value))) {
$('email_ticker').setHTML('<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">Email : This input value is not valid.</span>');
} else {
$('email_ticker').setHTML("<img src=\"<?php echo JURI::base()."images/wait.gif";?>\">&nbsp;Checking");
var url = 'index.php?option=com_virtuemart&tasked=chkuserinfo&format=raw&what=email';
url = url + '&email=' + form.email.value;

new Ajax(url, {
method: 'get',
onComplete: function(x){
if(x == 1) {
$('email_ticker').setHTML('<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">This email is already registered.</span>');
} else {
$('email_ticker').setHTML('<span style="border:1px none transparent;color:green;padding:5px 5px 5px 5px;">The email \''+ $('email_field').value +'\' is free for registration: you can proceed.</span>');
}
}
}).request();

}
}



</script>
        <?php



4. FILE: /components/com_virtuemart/virtuemart.php

AFTER THESE LINE
Code: [Select]
global $mosConfig_absolute_path, $product_id, $vmInputFilter, $vmLogger;
ADD THE CODES BELOW:
Code: [Select]
$tasked = JRequest::getVar( 'tasked' );

if($tasked=="chkuserinfo"){
$database = & JFactory::getDBO();
$email = JRequest::getVar( 'email' );
$uname = JRequest::getVar( 'uname' );

$what = JRequest::getVar( 'what' );

$usercount = 0;
$emailcount = 0;


if($what == "uname"){
$database->setQuery("SELECT COUNT(*) FROM #__users WHERE username='$uname'");
$usercount = $database->loadResult();
if($usercount)
echo "1";
else
echo "0";

} else if ($what == "email") {
$database->setQuery("SELECT COUNT(*) FROM #__users WHERE email='$email'");
$emailcount = $database->loadResult();

if($emailcount)
echo "1";
else
echo "0";
}


die();
}


ALSO MAKE SURE THE IMAGE BELOW IS UPLOADED INTO THE  /images DIRECTORY ON YOUR SERVER


I hope this will help. I expect feedback from your tests. Good luck to all.  :)

Is it possible to make this compatible with mootools 120? I must use mootools 120, but if I add this vmCommonHTML::loadMooTools(); they stop working!

Qzmarcia

  • Beginner
  • *
  • Posts: 7
Re: [SOLVED] ajax registration
« Reply #46 on: March 02, 2011, 21:10:11 pm »
VERY GOOD SOLUTIONS !!

I WANT NOW WHERE I CAN CHANGE THE TEXT: The username 'Qzkkkyan' is free for registration: you can proceed.

FOR MY NATIVE LANGUAGE.

TO REGARDS

QZ MARCIA

lindapowers

  • Full Member
  • ***
  • Posts: 1339
  • If you're going through hell, keep going.
    • Venta de naranjas online y mandarinas
  • Skype Name: manu.gonzalez91
  • VirtueMart Version: Latest avi
Re: [SOLVED] ajax registration
« Reply #47 on: March 03, 2011, 18:35:56 pm »
great... but I will wait until they add it officially.
http://www.comenaranjas.com - Navel oranges and clementines from Spain

cyran0

  • Beginner
  • *
  • Posts: 3
Re: [SOLVED] ajax registration [but still AUTO-LOGIN issue for some of us]
« Reply #48 on: March 16, 2011, 15:10:09 pm »
Hi

I successfully patch my 1.1.7 ver of VirtueMart ... thx a bunch, it is great : all the validations on the same page !

I have a related question which involve, I think, the same php pages.

With the email account activation in place, right after a successful registration why is the response page indicating a successful registration AND a login failure ?

Quote
Login denied! Your account has either been blocked or you have not activated it yet. Did you not get an activation e-mail and follow the validation link?

My guess is that there is some kind of auto-login which does not make sense for my setup since the new user must activate the account with the link inside the registration email first !

Lately, I applied another small patch which activates error messages, including the one above, through out the whole site, I added the line
    <jdoc:include type="message" />
into this file
    C:\xampp\htdocs\ecommerce\templates\ja_larix\index.php
ref: http://forum.virtuemart.net/index.php?topic=50465.0

I bet there is a simple way to deactivate the auto-login for this case. Somebody knows how ?

thx in advance

lindapowers

  • Full Member
  • ***
  • Posts: 1339
  • If you're going through hell, keep going.
    • Venta de naranjas online y mandarinas
  • Skype Name: manu.gonzalez91
  • VirtueMart Version: Latest avi
Re: [SOLVED] ajax registration
« Reply #49 on: April 01, 2011, 19:41:50 pm »
Man this would be great, read the entire post but so many codes and corrections I don't know where to start from. Someone has this working correctly in VM 1.1.8?
http://www.comenaranjas.com - Navel oranges and clementines from Spain

maxxer

  • Jr. Member
  • **
  • Posts: 73
Re: [SOLVED] ajax registration
« Reply #50 on: April 13, 2011, 12:35:19 pm »
I'm attaching here a full patch for VM 1.1.7.
Thanks for sharing this!

Patch will apply with
patch -p1 < filename

[attachment cleanup by admin]

lindapowers

  • Full Member
  • ***
  • Posts: 1339
  • If you're going through hell, keep going.
    • Venta de naranjas online y mandarinas
  • Skype Name: manu.gonzalez91
  • VirtueMart Version: Latest avi
Re: [SOLVED] ajax registration
« Reply #51 on: April 14, 2011, 10:30:29 am »
PATCH_verifica_utente.txt ????????????????????

Where does that file go and what is the name of that file? Oo
http://www.comenaranjas.com - Navel oranges and clementines from Spain

didi235

  • Beginner
  • *
  • Posts: 1
Re: [SOLVED] ajax registration
« Reply #52 on: May 04, 2011, 04:48:33 am »
This patch is great but i am having a problem with SSL. It seems to get stuck on the waiting image. Does anyone have this working with SSL?

sirius

  • Beginner
  • *
  • Posts: 29
    • OCTeam
Re: [SOLVED] ajax registration
« Reply #53 on: May 12, 2011, 17:32:19 pm »
Hi,
implemented on virtuemart 1.1.8 (2nd method with all the corrections of the topic except mootools call)
joomla 1.5.23

All is ok, except that all username and all emails are always free to use...
Simple test with some already registered username, return always green/free to use.

Any same cases as my own ?

Thanks

Derf

  • Beginner
  • *
  • Posts: 8
Re: [SOLVED] ajax registration
« Reply #54 on: May 26, 2011, 13:18:41 pm »
This is awesome, thanks so much!

A few questions:

1) How do I use the same system to validate matching passwords?
2) How can I implement the same system for all the fields in the VM registration (first name, last name, address, etc.)

Thanks a ton!

abcisme

  • Beginner
  • *
  • Posts: 11
Re: [SOLVED] ajax registration
« Reply #55 on: July 31, 2011, 15:58:33 pm »
But if we forget to input 1 required (*) field, after we click send, all the data we already typed become blank? And user will type it again?

Check out this post:  http://forum.virtuemart.net/index.php?topic=78676.0


drevokocur

  • Beginner
  • *
  • Posts: 44
Re: [SOLVED] ajax registration
« Reply #56 on: November 02, 2011, 11:18:50 am »
Tested on VirtueMart 1.1.2 stable. Works perfectly! Thanks!!!

AlfredJK

  • Beginner
  • *
  • Posts: 11
Re: [SOLVED] ajax registration
« Reply #57 on: August 09, 2012, 21:06:13 pm »
Hi, i know the topic is old but i have still te problem that the registration button scrolls down and only available by pressing the tab. I added the syntax
#register_stretcher input.button {margin-bottom: 54px;} but it didn't help. I'am using IE 9. Firefox and chrome works perfect!

HELP!

Roger Lightening

  • Jr. Member
  • **
  • Posts: 66
    • VisAbility: Joomla website developers
Re: [SOLVED] ajax registration
« Reply #58 on: May 26, 2014, 14:10:35 pm »
Thank you, thank you, thank you!
Your post has saved me hours of work. I manage a old VirtueMart website and this hack has probably saved me eight hours of work. Implemented the hack as per Vanci's post and it works perfectly.