1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
function ff_not_duplicate(element, message) { var error = false; JQuery.ajax({ url : "validacion.php", data : { "name":element.name, "value":element.value }, type : "POST", async : false, dataType : "json", success : function(response){ error = (response == "1" ? true : false); } }); if( error ) { if (message=='') message = element.name+" faild in my test.\n" ff_validationFocus(element.name); return message; } return ''; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
<?php //Esto se podria hacer mas elegante cogiendo los datos del fichero de configuracion de Joomla: define('MYSQL_HOST' , 'localhost' ); define('MYSQL_DBNAME' , 'DBNAME' ); define('MYSQL_USUARIO' , 'USUARIO' ); define('MYSQL_PASSWORD', 'PASSWORD' ); $result = "1"; if( isset($_POST) ) { try { $name = str_replace("[]_", "", str_replace("_ff_nm_", "", ("_" . $_POST["name"] . "_"))); $value = $_POST["value"]; $conexion = new PDO("mysql:host=" . MYSQL_HOST . ";dbname=" . MYSQL_DBNAME, MYSQL_USUARIO, MYSQL_PASSWORD); $stmt = $conexion->prepare("SELECT true AS result FROM joomla_facileforms_subrecords WHERE name = ? AND value = ?;"); $stmt->bindParam(1, $name ); $stmt->bindParam(2, $value ); $stmt->execute(); while( $row = $stmt->fetch() ) { $result = $row['result'] ? "1" : "0"; break; } $conexion = null; } catch( Exception $e ) { if( $conexion != null ) $conexion = null; //$result = $e->getMessage(); } } echo $result; ?> |