Hello all I am doing a form in php since drupal in which I have a text box and a push button, the input of a code (varchar) and this is compared to a record in sqlserver at the time of performing the validation Code entered In the form exists in the DB) executes an iframe with a stored procedure.
This is the code, I think I'm doing something wrong with the php code and select it because the moment of entering the value to query does not generate the text "all right" or the "number consulted does not exist" found in He does
I thank those who tell me to help and guide
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Buscador php</title>
<form method="POST" action="" onSubmit="return validarForm(this)">
<input type="text" placeholder="Buscar usuario" name="palabra">
<input type="submit" value="Buscar" name="buscar">
</form>
</meta>
<script type="text/javascript">
function validarForm(formulario)
{
if(formulario.palabra.value.length==0)
{ //¿Tiene 0 caracteres?
formulario.palabra.focus(); // Damos el foco al control
alert('Debes rellenar este campo'); //Mostramos el mensaje
return false;
} //devolvemos el foco
return true; //Si ha llegado hasta aquí, es que todo es correcto
}
</script>
</html>
</head>
<?php
//si existe una petición
if($_POST['buscar'])
{
$usuario= '';
$pass = '';
$servidor = '';
$basedatos = '';
$info = array('Database'=>$basedatos, 'UID'=>$usuario, 'PWD'=>$pass);
$conexion = sqlsrv_connect($servidor, $info);
if(!$conexion){
die( print_r( sqlsrv_errors(), true));
}
echo 'Conectado';
$buscar = $_POST["palabra"];
$arrojado = sqlsrv_query("SELECT ID from Venta
where ID like '%buscar%'",$conexion) or
die("Problemas en el select:".sqlsrv_error());
?>
//$resultado = sqlsrv_fetch_array($arrojado);
<?php
$valor = $resultado['aleatoria']; //LE ASIGNAMOS UNA VARIABLE AL RESULTADO DE LA CONSULTA
//COMPARAMOS CON UNA CONDICIONAL
if($arrojado == $buscar){
echo"todo bien";
}
else {
echo "El numero consultado no existe";
?>