Jump to content

Recommended Posts

I have a php script which is automatically checking whether the username is available or not...

 

<?php

session_start();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="css/form.css" media="screen" title="bbxcss" />
<script src="untitled_files/jquery-1.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="css/sexybuttons.css" media="screen" title="bbxcss" />

  <script src="untitled_files/jquery.js" type="text/javascript" charset="utf-8"></script>

  <script src="untitled_files/jquery-glowing.js" type="text/javascript" charset="utf-8"></script>

<style type="text/css" media="screen">

    #top {

      font-size: 64px;

      font-family:"bradley Hand ITC";

      font-weight: bold;
  

     
}
a{

	color:#000}
label{


      font-family:"bradley Hand ITC";

      font-weight: bold;
  width:200px;

	}

  </style>

<script type="text/javascript" charset="utf-8">

    $(document).ready(function() {

      $('.white').addGlow({ textColor: 'white', haloColor: '#aaa', radius: 100 });

      $('.blue').addGlow({ textColor: '#00f', haloColor: '#00f', radius: 100 });

      $('.green').addGlow({ textColor: '#0f0', haloColor: '#0f0', radius: 100 });

      $('.red').addGlow({ textColor: '#f00', haloColor: '#f00', radius: 100 });

      $('*').bind('glow:started', console.info);

      $('*').bind('glow:canceled', console.info);

    });

    

  </script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>:: FH ::</title>
</head>

<body><center><p><a  id="top" style="color: rgb(255,255,255);" class="red" >
Fire Hearts  Hisaab Portal</a></p><br /><Br />
</center>
<script type="text/javascript"> 
function showHint(str)
{
var xmlhttp;
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {


  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  //if(xmlhttp.readyState==3 || xmlhttp.readyState==2 ||xmlhttp.readyState==0||xmlhttp.readyState==1)

else
{ document.getElementById("txtHint").innerHTML="<img src=\"l.gif\"/>";

}
  }
xmlhttp.open("GET","check_usname.php?usname="+str,true);
xmlhttp.send();
}
</script>

<form name="form1" action="create.php" method="post">
<div style="float:right">
<a href="index.php"><input type="button"  class="sexybutton sexysimple sexyred" value="Home" name="registerbutt" style="width:150px;" /></a> <br />
<br /></div>
<font color="#FF0000" face="bradley Hand ITC">
<?php
if(isset($_SESSION['status']))
{
echo $_SESSION['status'];
unset ($_SESSION['status']);	
}
?></font><br />





<!-- XML CONTENT ------------>







<table>
<tr>
<td>
<label>Email : </label> <input type="text" name="email" placeholder="abcd@xyz.com" /><br /><br />
</td>
</tr>
<tr>
<td>
<label>Select your name :</label> <select name="usname2" >
  <option value="none">...</option>

  <option value="ankur">Ankur</option>
  <option value="archie">Archie</option>
  <option value="deepesh">Deepesh</option>
  <option value="jyoti">Jyoti</option>
  <option value="nikunj">Nikunj</option>
  <option value="pranshu">Pranshu</option>
  <option value="Vikas">Vikas</option>
</select><br /><br />
</td>
</tr>
<tr>
<td>
<label>Choose a Username : </label> <input type="text" name="usname" placeholder="Username" onkeyup="showHint(this.value)" />

<br />
<label id="txtHint"></label>
<br />
</td>
</tr>
<tr>
<td>
<label>Choose a Password : </label> <input type="password" name="password" placeholder="Password"  />
</td>
</tr>
<tr>
<td>
<input type="submit" name="submit" value="Register" />
</td>
</tr>

</table>
</form>

</body>
</html>

 

But there is a problem :  suppose user enters a username "abcdef123"

 

then it will check first for "a" then for "ab" and then for "abc".... and so on.....

 

So i wanted that it only checks for abcdef123 then what should i do....

 

- PRANSHU AGRAWAL

pranshu.a.11@gmail.com

Link to comment
https://forums.phpfreaks.com/topic/253155-loading/
Share on other sites

I am going to presume that your structure for your usernames will follow the usual rules, ie minimum 6 characters etc. So all yo will need to do is where it checks if the string length is 0 change it if str lengh is less than the mimimum length required for your usernames ( ie less than 6) this will stop it triggering the ajax on every keystroke

Link to comment
https://forums.phpfreaks.com/topic/253155-loading/#findComment-1297806
Share on other sites

Actualy wht i want is .... the js function for check username only executes when user stops entering words in the username field....

 

And after googling it a lot i found that i have to create a js function that checks whether user stops entering word and if it returns true i should call the ajax function ....

 

But i m not getting how to create that kinda js function... :(

Link to comment
https://forums.phpfreaks.com/topic/253155-loading/#findComment-1297807
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.