Guest User

Untitled

a guest
Oct 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. <label for="inp">Inserire codice fiscale</label>
  2. <input style="width: 100%;" id="inp" name="inp" type="text" />
  3. <div id="yeah" style="display: none;">show some text</div>
  4. <div id="no" style="display: none;">show another text</div>
  5.  
  6. $(function(){
  7. $('input[name=inp]').keyup(function(){
  8. var inpvalue= $('#inp').val();
  9. $.ajax({
  10. type: 'POST',
  11. data: ({p : inpval}),
  12. url: 'check.php',
  13. dataType: 'json',
  14. success: function(data) {
  15. if(data.status == 'success'){
  16. $('#yeah').show();
  17. $('#no').hide();
  18. }else{
  19. $('#yeah').hide();
  20. $('#no').show();
  21. }
  22. }
  23. });
  24. });
  25. });
  26.  
  27. <?
  28. function add_my_script() {
  29. wp_register_script(
  30. 'cf',
  31. get_stylesheet_directory_uri() . '/js/cf.js',
  32. array('jquery')
  33. );
  34.  
  35. wp_enqueue_script('cf');
  36. }
  37.  
  38. add_action( 'wp_enqueue_scripts', 'add_my_script' );
  39.  
  40. ?>
  41.  
  42. <?php
  43. $dbhost = 'localhost';
  44. $dbuser = 'user';
  45. $dbpass = 'pass';
  46. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  47.  
  48.  
  49. if(! $conn ) {
  50. die('Could not connect: ' . mysql_error());
  51. }
  52.  
  53. $cf = $_POST['p'];
  54. string strtoupper (string $cf);
  55.  
  56. $sql1 = "SELECT cf FROM table WHERE cf='$cf'";
  57.  
  58. mysql_select_db('database');
  59. $retval1 = mysql_query( $sql1, $conn );
  60.  
  61. $count1 =0;
  62.  
  63.  
  64. if(!$retval1) {
  65. die('Could not enter data: ' . mysql_error());
  66. }
  67.  
  68. while($row = mysql_fetch_array($retval1, MYSQL_ASSOC)) {
  69. $count1 = $count1 + 1;
  70. }
  71.  
  72. mysql_close($conn);
  73.  
  74. if($count1 > 0){
  75. $response_array['status'] = 'success';
  76. header('Content-type: application/json');
  77. echo json_encode($response_array);
  78. }
  79.  
  80. ?>
Add Comment
Please, Sign In to add comment