Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
AJAX Check Username on Signup
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

Unknown User
2020-05-10 14:52:15
Just use SELECT count(id) so that database needs to read only 1 column.

Here's my example with vanilla javascript as I hate jquery.

For a quick test, save as test.php

<?php
include 'backend/functions.php';
dbconn();

// This is the PHP side ajax check
if (isset($_GET['ajax']) && $_GET['ajax'] === '1')
{
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
$username = sqlesc($_POST['username']);
$stmt = SQL_Query_exec("SELECT COUNT(id) as username FROM users WHERE username = $username");
$row = mysqli_fetch_assoc($stmt);

if ($row['username'] < 1)
{
$response = '<font color="green">This username is available</font>';
}
else
{
$response = '<font color="red">This username is not available</font>';
}
echo $response;
die;
}
}

stdhead('username check');
begin_frame('username check');
?>
<form method="post">
Username: <input type="text" onkeyup="usernameCheck(this.value)" name="username" /> <span id="usernameStatus"></span>
</form>

<script>
function usernameCheck(str)
{
// This is just a browser side protection (Check usernames only if username has more than 3 letters)
if (str.length < 3) {
   return false;
}

// Define AJAX XMLHTTP
// Modern browsers
if (window.XMLHttpRequest)
{
   xhttp = new XMLHttpRequest();
}
// I.E 6
else
{
   xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
var url = '?ajax=1';
var params = 'username=' + str;
xhttp.open("POST", url, true);

// Send the proper header information along with the request
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

// What to do with the response
 xhttp.onreadystatechange = function()
 {
   if (this.readyState === 4 && this.status === 200)
   {
     document.getElementById("usernameStatus").innerHTML = this.responseText;
   }
 };
// Send the post fields
 xhttp.send(params);
// Until data returned, show custom text
 document.getElementById("usernameStatus").innerHTML = "Processing...";
}
</script>
<?php
end_frame();
stdfoot();
2020-06-24 15:05:37
it would be nice to do the same with email ;)
2020-06-24 17:57:46
Adjust the change username to email or duplicate it so both fields check.
2020-06-25 17:58:38
"STorrents2020, post: 68755, member: 20382":

Adjust the change username to email or duplicate it so both fields check.

indeed, a test. at my vacation lol ?
2020-07-03 00:23:41
Did you get email working?
2020-07-03 01:09:24
not at the moment, no time tested lol
2020-07-04 20:02:11
You want to replace LIKE :username with :email assuming ternary operator isn’t used instead. I’m not at my files at the moment. This should be in the Ajax ZIP
2020-07-05 13:33:50
Après quelque tentative j'ai finalement fini par faire fonctionner avec le email du membre.
===========================================================================
After some attempt I finally ended up working with the member's email

In [color=rgb(243, 121, 52)]account-signup.php[/color] search :

<td><?php echo T_("EMAIL"); ?>: <font class="required">*</font></td>
<td><input type="text" size="40" name="email" /></td>


Replace for :

               <td><?php echo T_("EMAIL"); ?>: <font class="required">*</font></td>
               <td><input type="text" size="40" name="email" id="validemail" class="hintanchor"  /></td>            
   <!-- Response -->
   <div id="uname_response"></div>
   <script type="text/javascript">
   $(document).ready(function() {
   $("#validemail").keyup(function() {
       var a = $(this).val().trim();
       if ("" != a) {
           $("#uname_response").show();
           $.ajax({
               url: "./ajax_checkemailname.php", /* Use absolute url if you are using rewritten urls */
               type: "post",
               data: {
                   email: a
               },
               success: function(a) {
                   $("#uname_response").html(a);
               }
           });
                   } else $("#uname_response").hide();
               });
           });
           </script>                
           </tr>


[color=rgb(209, 72, 65)]*[/color] Ajouter le fichier[color=rgb(243, 121, 52)] ajax_checkemailname.php[/color] a la racine de votre site.
=============================================================
[color=rgb(209, 72, 65)]*[/color] Add the [color=rgb(243, 121, 52)]ajax_checkemailname.php[/color] file to the root of your site.


Example img:
[ATTACH type="full" width="587px"]5599[/ATTACH]
Capture.PNG
Capture.PNG

2021-02-24 23:46:35
STorrents2020: yes email M8...#1
2022-08-02 21:32:01
I share with you my creation effect for those like me has several colors on the default themes for text errors or not visible.


Add this line at the end of your theme .css file:
/* Mode AJAX Check Username on Signup by STorrents2020 2022 + css by spiritblue */
.usersignuperror{
   letter-spacing: 2px;
   background: linear-gradient(90deg, #edf150, #fff, #000); /*3 colores*/
   background-repeat: no-repeat;
   background-size: 80%;
   animation: animate 7s infinite; /*Scroll speed*/
   -webkit-background-clip: text;
   -webkit-text-fill-color: rgba(255, 255, 255, 0);/*Color text-fill rgb*/
}
   @keyframes animate {
   0% {
   background-position: -500%;
   }
   100% {
   background-position: 500%;
   }
}


Add 2x Class selector after the <span tag:
class='usersignuperror'


Exanple:
$response = "<br/><div class=ttable_head><br/><span class='usersignuperror' style='color: #00FF00;font-family: Papyrus;font-size: 28px;padding-top: -5px;'> <font color='#fff' size='6'>☺</font> Nom d'utilisateur disponible  <br/></span><br/></div><br/>";
if ($count > 0) {
   $response = "<br/><div class=ttable_head><br/><span class='usersignuperror' style='color:red;font-family: Papyrus;font-size: 28px;padding-top: -5px;'> <font color='#fff' size='6'>☠</font> Nom d'utilisateur non disponible <font color='#fff' size='6'>☠</font><br/> </span>  </div><br/>";
}

NOTE:You can also do the same for email, just change the name of your usersignuperror class to mailsignuperror

I have added comments to facilitate the personal change for you and your theme.
Let me know if needed.

I thank you the author and the participants 👍
Last edited by spiritblue on 2022-08-02 21:33:20
2022-08-05 05:06:56
Yes Ive done this to images too using a instagram-like border with blended colors. keyframes is great!
2022-08-05 23:12:48
STorrents2020:
Yes Ive done this to images too using a instagram-like border with blended colors. keyframes is great!

yes indeed possible to do with a border with background image or add a border image also with

border: 40px groove transparent;
  -webkit-border-image: url(images/example.png) 13% round; /* Safari 3.1-5 */
  -o-border-image: url(images/example.png) 13% round; /* Opera 11-12.1 */
   border-image: url(images/example.png) 13% round /* Firefox 103.0.1 */;


...css fun to be able to almost everyone!  😊
Last edited by spiritblue on 2022-08-05 23:16:16
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728