49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
|
<?php ini_set('display_errors', 'On'); ?>
|
||
|
<html >
|
||
|
<head>Ejercicio</head>
|
||
|
<body>
|
||
|
<?php
|
||
|
$num1 = rand(0,9);
|
||
|
$num2 = rand(0,9);
|
||
|
$num0 = $num1 + $num2;
|
||
|
?>
|
||
|
|
||
|
<form name="mi_perro" action="prueba.php" method="post">
|
||
|
Escribe el nombre de tu perri:
|
||
|
<input type="text" name="elperro" valie= " "><br>
|
||
|
Escribe el resultado de la operación:
|
||
|
<?php
|
||
|
print "$num1 + $num2";
|
||
|
?>
|
||
|
<input type='text' name='codigo'>
|
||
|
<?php
|
||
|
if(validacion(mi_perro, codigo) == true){
|
||
|
$imagen .= $i . ".jpg";
|
||
|
$mostrarimagen = imagecreatefromjpeg("$imagen");
|
||
|
imagejpeg($mostrarimagen);
|
||
|
}else{
|
||
|
(string) $nocoincide = "Error de búsqueda";
|
||
|
print $nocoincide;
|
||
|
}
|
||
|
?>
|
||
|
</form>
|
||
|
|
||
|
<?php
|
||
|
// print "holamundo";
|
||
|
$perros = array("alpha, cankiss, lara, acrux, amed");
|
||
|
function validacion($nombre, $codigo){
|
||
|
|
||
|
$i=" ";
|
||
|
$imagen="imagen";
|
||
|
$bool = false;
|
||
|
for($i = 0; $i < 4; $i++){
|
||
|
if(($nombre==$perros[$i]) and ($codigo == $num0)){
|
||
|
$bool = true;
|
||
|
}
|
||
|
}
|
||
|
return ($bool);
|
||
|
}
|
||
|
?>
|
||
|
</body>
|
||
|
</html>
|