Ir ao conteúdo

Posts recomendados

Postado

Eu estou fazendo um site para designer gráfico e estou tendo dificuldade para ler o arquivo do código captcha que gera uma imagem de verificação, algo simples para este projeto não precisaria de nada muito profissional. Ainda o formulário vai ser devidamente estilizado.

 

// captcha.php

<?php
/*
 * @link http://phpform.net/math_captcha.php
 */
session_start();
// value 1
$numOne = rand(1, 9);
// value2
$numTwo = rand(1, 9);
// total
$numero = $numOne + $numTwo;
// math string
$display = $numOne . '+' . $numTwo . ' = ';
// set session variable to total
$_SESSION['check'] = $numero;
/*
 * @link http://www.digimantra.com/technology/create-image-in-php-using-gd-with-different-font-size/
 */
// set image size (pixels)
// imagecreate( [width], [height] )
$img = imagecreate( 75, 38 );
// choose a bg color, you can play with the RGB values
// imagecolorallocate( [image], [red], [green], [blue] )
$background = imagecolorallocate( $img, 255, 255, 255 );
//chooses the text color
// imagecolorallocate( [image], [red], [green], [blue] )
$text_colour = imagecolorallocate( $img, 33, 37, 41 );
//pulls the value passed in the URL
$text = $display;
// place the font file in the same dir level as the php file
$font = 'verdana.ttf';
//this function sets the font size, places to the co-ords
// imagettftext( [image], [size], [angle], [x], [y], [color], [fontfile], [text] )
imagettftext($img, 20, 4, 4, 26, $text_colour, $font, $text);
//alerts the browser abt the type of content i.e. png image
header( 'Content-type: image/png' );
//now creates the image
imagepng( $img );
//destroys used resources
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $img );

// Contato.php

<div class="container">
<form class="form-signin" method="post">
<h2 class="form-signin-heading"></h2><BR>
        
        <label for="Nome">Nome:</label>
        <input type="text" name="nome" id="nome" class="form-control" placeholder="" required>
        <label for="email">E-mail:</label>
	<input type="email" name="email" id="email" class="form-control" placeholder="" required>
	<label for="Telefone">Telefone:</label>
        <input type="text" name="telefone" id="inputTel" class="form-control" placeholder="" required>
        <label for="Telefone">Mensagem:</label>
	<textarea class="form-control" cols="20" id="mensagem" name="mensagem" rows="10" required></textarea>       
	
        <div class="row">
	<div class="col-md-12">
			    
        <img src="captcha.php" id="captchaImage" alt="Captcha Image">
	<label for="captchaAnswer" class="sr-only">Captcha Answer</label>
	<input type="text" class="form-control text-center" id="captchaAnswer" name="check">    

	<BR>
	</div>
	     
       <div class="col-sm-12">
       <button class="btn btn-danger btn-lg" name="submit" type="submit">
       Enviar
       </button>
       </div>
       </div>
       </div>
       </form>
  
       <?php

image.thumb.png.79af2edffc0001d090585d04058a9695.png

 

Crie uma conta ou entre para comentar

Você precisa ser um usuário para fazer um comentário

Criar uma conta

Crie uma nova conta em nossa comunidade. É fácil!

Crie uma nova conta

Entrar

Já tem uma conta? Faça o login.

Entrar agora

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...