Buenas jeje soy nuevo en el foro :p pero quiero aprender mas de este lenguaje.
Bueno yo quisiera saber si alguien conoce este codigo para poder entrar a una pagina web con una imagen de verificacion.
Ejemplo:
quitar los espacios.
El codigo de verificacion de php que tengo este.
image_login_verify.php
Código:
<?php
session_start();
// generate 5 digit random number
$rand = rand(10000, 99999);
// create the hash for the random number and put it in the session
$_SESSION['image_random_value'] = md5($rand);
// create the image
$image = imagecreate(50, 18);
// use white as the background image
$bgColor = imagecolorallocate ($image, 0x00, 0x00, 0x00);
// the text color is black
$textColor = imagecolorallocate ($image, 0xA0, 0XA0, 0xA0);
// write the random number
imagestring ($image, 4, 3, 1, $rand, $textColor);
// send several headers to make sure the image is not cached
// taken directly from the PHP Manual
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
// send the content type header so the image is displayed properly
header('Content-type: image/jpeg');
// send the image to the browser
imagejpeg($image);
// destroy the image to free up the memory
imagedestroy($image);
?>
En el Index agrege.
Código:
<script language="Javascript" type="text/javascript">
function check_id2()
{
if ( document.login_account.login.value == "")
{
alert("Por favor, introduzca su nombre de usuario.");
return false;
}
if ( document.login_account.pass.value == "")
{
alert("Por favor, introduzca su contraseña.");
return false;
}
if ( document.login_account.verifyinput2.value == "")
{
alert("Escribir el Codigo de Verificacion.");
return false;
}
//return false;
document.login_account.submit();
}
</script>
Panel de cuenta
Código:
<?php if ((isset($_SESSION['pass'])) && (isset($_SESSION['user'])))
{
echo "<form action='' method='post' name='logout_account' id='logout_account'>
<table width='160' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td height='15' colspan='2' scope='row' class='style16'><div align='center'>Bienvenido!!</td></div>
</tr>
<tr>
<td height='15' colspan='2' scope='row' class='style16'><div align='center'>Estas conectado como</td></div>
</tr>
<tr>
<td height='20' colspan='2' scope='row' class='style18'><div align='center'>$_SESSION[user]</td>
<input name='logoutaccount' type='hidden' id='logoutaccount' value='logoutaccount'></td></div>
</tr>
<tr>
<th width='160' height='33' scope='row'><div align='center'>
<input name='Submit' type='image' src='template/season4/images/logout_button.gif' border='0' title='SALIR'></td>
</div></th>
</tr>
<tr>
<td width='160' height='25' scope='row'><div align='center' title='Panel de Control' ><a href='index.php?menu=usuario'><font color='#ffffff'>Panel de Control</font></a></div></td>
</tr>
</table>
</form>";
}
else
{
echo "<form action='' method='post' name='login_account' id='login_account'>
<table style='width: 100%; height: 132px' cellspacing='0' cellpadding='0'>
<tr>
<td style='width:2px; height: 73px'>
</td>
<td style='height: 73px'>
<table style='width: 96%; height: 71px' cellspacing='0' cellpadding='0'>
<tr>
<td style='width: 156px'>
<table style='width: 92%; height: 75px;' cellspacing='0' cellpadding='0'>
<tr>
<td class='style16' style='height: 10px'>
Usuario</td>
</tr>
<tr>
<td>
<input name='login' type='text' class='input_login' id='login' title='Usuario' size='15' maxlength='10' style='height: 16px; width: 90px;'><input name='account_login' type='hidden' id='account_login' value='account_login'></td>
</tr>
<tr>
<td class='style16' style='height: 10px'>
Contraseña</td>
</tr>
<tr>
<td>
<input name='pass' type='password' class='input_login' id='pass' title='Contraseña' size='15' maxlength='10' style='height: 16px; width: 90px;'></td>
</tr>
</table>
</td>
<td>
<table style='width: 70px; height: 78px' cellspacing='0' cellpadding='0'>
<tr>
<td style='height: 24px'></td>
</tr>
<tr>
<td style='height: 35px'>
<input name='Submit' type='image' src='template/season4/images/button_login.gif' style='border: 0px solid #000000;' onclick='return check_id2()' title='ENTRAR'></td></tr>
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style='width:2px; height: 15px'></td>
<td style='height: 15px' class='style16'>Código de verificación</td>
</tr>
<tr>
<td style='width:2px; height: 10px'></td>
<td style='height: 10px'>
<table style='width: 100%' cellspacing='0' cellpadding='0'>
<tr>
<td style='width: 78px'>
<input name='verifyinput2' type='text' class='input_login' id='verifyinput2' size='7' maxlength='5'>
</div>
</td><td><img src='sys_/plugins/image_login_verify.php'></td>
</tr>
</table>
</td>
</tr>
<tr>
<td style='width:2px; height: 25px'></td>
<td style='height: 25px' class='style16'><a href='index.php?menu=recuperarcontraseña'><font color='#ffffff'>Olvidaste tu contraseña?</font></a></td>
</tr>
</table>
</form>";
} ?>
ok esto me funciona, me pide el codigo cuando no lo escribo el problema es que no verifica si esta bien escrito entro a la web sin estar bien escrito.