mysql - Jquery, ajax post and get results? -


i making login, want ajax post each key stroke query. when login matches login in database (mysql), want password returned parent page. now. have in past used ajax post php databases, never had return variable back. not know if passing form info over, thanks!

index.php script:

$(function(){      $("#inputemail").keyup(function() {     var usernameinput = $(this).val();         $.ajax({             type: "post",             url: "pulluserdb.php",             data: { 'usernameinput':usernameinput },             datatype: "text",             success: function(data)             {             $('.body').html(data);             }         });     });  }); 

index.php html:

 <div class = "headerlogin">         <form class="loginform">             <div class="control-group">                     <div class="controls">                     <input style = "height: 30px" type="text" id="inputemail" placeholder="email">                 </div>             </div>             <div class="control-group">                 <div class="controls">                 <input style = "height: 30px" type="password" id="inputpassword" placeholder="password">                 </div>             </div>             <div class="control-group">                 <div class="controls">                     <button style = "width: 200px" type = "button" class="submitlogin">sign in</button>                 </div>             </div>         </form>     </div> 

pulluserdb.php:

<?php //connect server $db_server = mysql_connect('localhost','root',''); if(!$db_server) die("unable connect mysql: " . mysql_error()); ?>  <?php //connect database mysql_select_db('databases')     or die("unable select database: " . mysql_error()); ?>  <?php $input_username = $_post['usernameinput']; //pull columns , store them variables $query_users = "select *                  users                  username = '".$input_username."'";  $result_users = mysql_query($query_users); if (!$result_users) die ("database access failed: " . mysql_error());  while($row_user_fetch = mysql_fetch_array($result_users))    {         $username = $row_users_fetch['username'];         $password = $row_users_fetch['password'];         $email = $row_users_fetch['email'];         echo $email;    } ?> 

i figured out! code has been edited show others need it! following code echo email of corresponding user body class div when enter username.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -