login, senha e captcha
Olá pessoal O sistema de login e senha abaixo está funcionando normalmente. O script captcha também está funcionando. Quero ligar o captcha com o sistema de login e senha e que funcione da seguinte forma: Se login, senha e captcha não forem digitados corretamente, impedir usuario de logar
acessar link e fazer download dos arquivos captcha
tag_logar
gg_id ggLogin ggSenha
1 joao 123
...
<?php
$ggCon = mysqli_connect("localhost", "root", "759", "bd_teste" );
if(mysqli_connect_error()){
echo "falha na conexão". mysqli_connect_error();
}
else{ echo "CONEXAO OK 1"; }
$phpSelf = $_SERVER['PHP_SELF'];
?>
<?php
function funcCaptcha($text){
$width = 200;
$height = 100;
$fontfile = "OpenSans-Regular.ttf";
$image = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
imagefill($image, 0, 0, $white);
imagettftext($image, 25, rand(-20,20), $width/4, 60, $black, $fontfile, $text);
$warped_image = imagecreatetruecolor($width, $height);
imagefill($warped_image, 0, 0, imagecolorallocate($warped_image, 255, 255, 255));
for ($x=0; $x < $width; $x++) {
# code...
for ($y=0; $y < $height; $y++) {
# code...
$index = imagecolorat($image, $x, $y);
$color_comp = imagecolorsforindex($image, $index);
$color = imagecolorallocate($warped_image, $color_comp['red'], $color_comp['green'], $color_comp['blue']);
$imageX = $x;
// $imageY = $y + sin($x / 10) * 10;
$imageY = $y + sin($x / 10) ;
imagesetpixel($warped_image, $imageX, $imageY, $color);
}
}
$path = "capacha.jpg";
imagejpeg($warped_image,$path);
imagedestroy($warped_image);
imagedestroy($image);
return $path;
}
$text88 = rand(10000,99999);
$myimage = funcCaptcha($text88);
// file_put_contents($filename, $text88);
?>
<?php if(isset($_POST["enviar"])){?>
<?php
@$gg_id = $_POST['gg_id'];
@$ggLogin = $_POST['ggLogin'];
@$ggSenha = $_POST['ggSenha'];
@$ggCaptcha = $_POST['ggCaptcha'];
?>
<?php
$sqlVF = mysqli_query($ggCon, "SELECT * FROM tab_logar WHERE
ggLogin = '".$ggLogin."' AND
ggSenha = '".$ggSenha."' ");
$AcompararDados = mysqli_num_rows($sqlVF);
?>
<?php
if($AcompararDados == true){
$_SESSION['gg_id'] = $gg_id;
print "usuário logado";
}
else{
print "não logou";
}
// $filename = session_id();
// if(count($_POST)>0){
// $ggCaptcha = file_get_contents($filename);
// if($_POST['ggCaptchak'] == $ggCaptcha){
// print "usuário logado";
// }
// else{
// print "não logou";
// }
// }
// $text = rand(10000,99999);
// $myimage = funcCaptcha($text);
// file_put_contents($filename, $text);
?>
<?php }?>
<form action="<?php echo $phpSelf;?>" method="post" name="form1" id="tete" autocomplete="on" style="margin:auto; width: 200px; padding: 1em;">
<h1 class=" e10CENTRO_h1_1">Acessar painel</h1>
Login <input type="text" name="ggLogin" value="" />
Senha <input type="text" name="ggSenha" value="" />
Digite o código<input type="text" name="ggCaptcha" value="" />
<img src="capacha.jpg" style="width:150px;" alt="código captcha"><br>
<input type="submit" name="enviar" value="Acessar" />
</form>Discussão (2)
Carregando comentários...