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

woonydanny

  • Jr. Member
  • **
  • Posts: 110
Re: [SOLVED] ajax registration
« Reply #15 on: January 26, 2010, 06:04:12 am »
so does this work for users? im still not sure if it is 100% working

Everest

  • Beginner
  • *
  • Posts: 4
Re: [SOLVED] ajax registration
« Reply #16 on: February 25, 2010, 07:48:13 am »
There are two errors with var "uname". I corrected them so far everything seems to work as designed. I don't put it on production site though.
UPDATE
as of march 1 2010 ajax works fine but no data except login first and last name is entered into mysql table.

zurli

  • Beginner
  • *
  • Posts: 1
    • Badetrends
Re: [SOLVED] ajax registration
« Reply #17 on: March 05, 2010, 00:43:14 am »
Thank you very much for this hack. I was looking for this because register form is not best thing in VM.

it is working very good. please see picture. all databasefields are filled with data.  ::)



[attachment cleanup by admin]

Everest

  • Beginner
  • *
  • Posts: 4
Re: [SOLVED] ajax registration
« Reply #18 on: March 07, 2010, 19:48:44 pm »
Oops, there was a bit of confusion over this hack. I admit it works. Thanks guys for sharing nice stuff!

Engholm

  • Beginner
  • *
  • Posts: 23
    • pixeldiele mediendesign
Re: [SOLVED] ajax registration
« Reply #19 on: March 25, 2010, 12:38:09 pm »
Works fine with J1.5.15 and VM 1.1.4. This should be a native function in VM!

Hermes

  • Jr. Member
  • **
  • Posts: 73
    • Antimatter-Studios
Re: [SOLVED] ajax registration
« Reply #20 on: April 08, 2010, 02:56:36 am »
Hi everyone!

Tested in J1.5.15 and VM 1.1.4 and afetr change the two errors in the variable uname, works perfect for me too.

I have a question about this hack. I'd like to use this code in the joomla normal registration, in addition of in my virtuemart registration form. I think that I know where to put the code inside files checkout_register_form.php and ps_userfield.php in my joomla installation, but I'm not pretty sure where to put the code inside file virtuemart.php in the joomla core.

¿Maybe In index.php? ¿Where  are the queries located in Joomla core?

¿Someone knows the answer?
It would be very nice to make work also this code in Joomla normal registration.

Thanks in advance!

Venci Gentchev

  • Jr. Member
  • **
  • Posts: 62
    • Bulgarian Computer Store
Re: [SOLVED] ajax registration
« Reply #21 on: April 08, 2010, 08:38:57 am »
I do not think that works normally. There are some problems.
User data is recorded normally, but then your account is not showing your email address and user name.

Venci Gentchev

  • Jr. Member
  • **
  • Posts: 62
    • Bulgarian Computer Store
Re: [SOLVED] ajax registration
« Reply #22 on: April 08, 2010, 12:46:25 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.  :)

[attachment cleanup by admin]

daviddickens

  • Beginner
  • *
  • Posts: 2
Re: [SOLVED] ajax registration
« Reply #23 on: April 16, 2010, 12:06:26 pm »
Problem detected with registration page from the checkout.  The "Send registration" button disappears as soon as the username checker is activated.

Any solution for this problem?

mbit

  • Full Member
  • ***
  • Posts: 323
Re: [SOLVED] ajax registration
« Reply #24 on: April 16, 2010, 12:19:31 pm »
Problem detected with registration page from the checkout.  The "Send registration" button disappears as soon as the username checker is activated.

Any solution for this problem?
same issue here.
 of this hack comes out the button is hidding in the footer :/
is there a way to reveal the message next of the field and not below it?

Venci Gentchev

  • Jr. Member
  • **
  • Posts: 62
    • Bulgarian Computer Store
Re: [SOLVED] ajax registration
« Reply #25 on: April 16, 2010, 13:50:57 pm »
Add to your theme.css

Code: [Select]
#register_stretcher input.button {margin-bottom: 54px;}
Оr change the value according to your template.
If you use a template that has a similar field (like Mynxx), just change the value.


mbit

  • Full Member
  • ***
  • Posts: 323
Re: [SOLVED] ajax registration
« Reply #26 on: April 16, 2010, 17:50:42 pm »
Add to your theme.css

Code: [Select]
#register_stretcher input.button {margin-bottom: 54px;}
Оr change the value according to your template.
If you use a template that has a similar field (like Mynxx), just change the value.


Thank you ! this is what was missing! :)

Venci Gentchev

  • Jr. Member
  • **
  • Posts: 62
    • Bulgarian Computer Store
Re: [SOLVED] ajax registration
« Reply #27 on: April 16, 2010, 23:35:31 pm »
Nice error in VirtueMart.  ;D

Go to the page to change your account settings and change your email address with:

Code: [Select]
ewerwerwerwyterwutfrde@asdas
or

Code: [Select]
ewerwerwerwyterwutfrde@asdas.comco
Or just try to register similar or greater in length email addresses.

Explorer crashes, right?  ;D Problem in the script.
Mozilla can handle, but IE .....
If I am a buyer, I will never enter this site again.
I would hardly think that is my fault and is in the spelling of the email.


How to fix it:

From:
Code: [Select]
if( !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value))) {
To:
Code: [Select]
if( !(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(form.email.value))) {

Where:

/administrator/components/com_virtuemart/classes/ps_userfield.php
(2 positions if you use this hack. Otherwise, one position)

/administrator/components/com_virtuemart/html/checkout_register_form.php
(1 position if you use this hack.)


daviddickens

  • Beginner
  • *
  • Posts: 2
Re: [SOLVED] ajax registration
« Reply #28 on: April 20, 2010, 07:50:58 am »
Add to your theme.css

Code: [Select]
#register_stretcher input.button {margin-bottom: 54px;}
Оr change the value according to your template.
If you use a template that has a similar field (like Mynxx), just change the value.



Thank you! It works.

Hermes

  • Jr. Member
  • **
  • Posts: 73
    • Antimatter-Studios
Re: [SOLVED] ajax registration
« Reply #29 on: April 21, 2010, 02:20:59 am »
I'm using your hack, and in the case of the email tester I'm using the same regular expresion that uses PhpMailer. I'm sure that these guys knows more than me about regular expresions, in fact, works perfect, and works with some very complicated emails that can't be validated with your script. I only have tested with Navigators that works in Mac Platform. So, If you can test with IE Explorer 6-7&8, it would be nice to know if works as well as in the Mac Platform.

The regex is:

Code: [Select]
if( !(/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/.test(form.email.value)))


Thanks for this Hack Man!

Bye!