Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <label for="inp">Inserire codice fiscale</label>
- <input style="width: 100%;" id="inp" name="inp" type="text" />
- <div id="yeah" style="display: none;">show some text</div>
- <div id="no" style="display: none;">show another text</div>
- $(function(){
- $('input[name=inp]').keyup(function(){
- var inpvalue= $('#inp').val();
- $.ajax({
- type: 'POST',
- data: ({p : inpval}),
- url: 'check.php',
- dataType: 'json',
- success: function(data) {
- if(data.status == 'success'){
- $('#yeah').show();
- $('#no').hide();
- }else{
- $('#yeah').hide();
- $('#no').show();
- }
- }
- });
- });
- });
- <?
- function add_my_script() {
- wp_register_script(
- 'cf',
- get_stylesheet_directory_uri() . '/js/cf.js',
- array('jquery')
- );
- wp_enqueue_script('cf');
- }
- add_action( 'wp_enqueue_scripts', 'add_my_script' );
- ?>
- <?php
- $dbhost = 'localhost';
- $dbuser = 'user';
- $dbpass = 'pass';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass);
- if(! $conn ) {
- die('Could not connect: ' . mysql_error());
- }
- $cf = $_POST['p'];
- string strtoupper (string $cf);
- $sql1 = "SELECT cf FROM table WHERE cf='$cf'";
- mysql_select_db('database');
- $retval1 = mysql_query( $sql1, $conn );
- $count1 =0;
- if(!$retval1) {
- die('Could not enter data: ' . mysql_error());
- }
- while($row = mysql_fetch_array($retval1, MYSQL_ASSOC)) {
- $count1 = $count1 + 1;
- }
- mysql_close($conn);
- if($count1 > 0){
- $response_array['status'] = 'success';
- header('Content-type: application/json');
- echo json_encode($response_array);
- }
- ?>
Add Comment
Please, Sign In to add comment