Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function()
- {
- $("#name").keyup(function()
- {
- var name = $(this).val();
- if(name.length > 3)
- {
- $("#result").html('checking...');
- $.ajax({
- type : 'POST',
- url : 'username-check.php',
- data : $(this).serialize(),
- success : function(data)
- {
- $("#result").html(data);
- }
- });
- return false;
- }
- else
- {
- $("#result").html('');
- }
- });
- });
- <div class="form-group">
- <div class="row" style="margin-left:40%;">Nome: <input class="form-control" type="text" name="name" id="name" placeholder="Inserisci Nome" style="width:40%!important;margin-left:5px;height:20px;font-size:small;" required><div class="disponibile"><span id="result"></span></div></div>
- </div>
- $host="localhost";
- $user="xxx";
- $pass="";
- $dbname="xxx";
- $myconn = mysql_connect($host, $user, $pass) or die('Errore...');
- mysql_select_db($dbname, $myconn) or die('Errore...');
- if($_POST)
- {
- $name = strip_tags($_POST['name']);
- $stmt=$dbcon->prepare("SELECT * FROM utenti WHERE nome=:name");
- $stmt->execute(array(':name'=>$name));
- $count=$stmt->rowCount();
- if($count>0)
- {
- echo "<span style='color:brown;'>Il nome è già attualmente in uso.</span>";
- }
- else
- {
- echo "<span style='color:green;'>Il nome è disponibile!
- </span>";
- }
- }
Add Comment
Please, Sign In to add comment