php - Asynchronous request in database -
there code:
<form name="step1" action="step2.php" method="post"> email: <input type="text" name="email" class="input-medium"> <button class="btn btn-small btn-warning" type="submit">check</button> </form>
and that: step2.php
<?php $email = $_post['email']; $result = mysql_query("select email,discount buyers email='$email'"); if (mysql_num_rows($result) <= 0) { echo "are new client is't it? <br>"; echo "your discount 0%<br>"; } else{ echo "<br/>nice see again! <br/>"; $getsalary = mysql_fetch_array($result); echo "you discount already: "; echo $getsalary[discount]; echo " %"; } ?>
so, possible request in database without submit form , redirect new page (step2.php in example)? mean, query result shown immediately.. think onblur() method, don't know how create similar request javascript. maybe possible ajax?
i grateful advice. thx lot.
in <head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script> function jqajaxform(data2send, file2send, dataconteiner) { if(data2send.indexof("#") != -1){ data2send = jquery(data2send).serialize(); } jquery(dataconteiner).html("<option>loading...</option>"); jquery.ajax({ type : "post", url : file2send, data : data2send, success : function(data){ jquery(dataconteiner).html(data); }, error : function(data){ jquery(dataconteiner).html(data); }, cache : false }); } </script>
instead in body
<body> <div id="target"><div> <form name="step1" action="step2.php" method="post" id="form"> email: <input type="text" name="email" class="input-medium"> <button class="btn btn-small btn-warning" type="submit" on click = "jqajaxform('#form', 'step2.php','#target')">check</button> </form> </body>
Comments
Post a Comment