I am new in php and i want to do capthca ... I wrote the code, validation etc , and as a result i get only small picture ... and nothing on it ... and my program dont tell me where is an error
This is my code in captcha.php:
<?php
session_start();`enter code here`
// build the base captcha image
$img = imagecreatetruecolor(80,30);
$white = imagecolorallocate($img, 255, 255, 255);
$black = imagecolorallocate($img, 0, 0, 0);
$grey = imagecolorallocate($img,150,150,150);
$red = imagecolorallocate($img, 255, 0, 0);
$pink = imagecolorallocate($img, 200, 0, 150);
// build the base captcha image - END
// building randomString
function randomString($length){
$chars = "abcdefghijkmnopqrstuvwxyz023456789";
srand((double)microtime()*1000000);
$str = "";
$i = 0;
while($i <= $length){
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$str = $str . $tmp;
$i++;
}
return $str;
}
for($i=1;$i<=rand(1,5);$i++){
$color = (rand(1,2) == 1) ? $pink : $red;
imageline($img,rand(5,70),rand(5,20), rand(5,70)+5,rand(5,20)+5, $color);
}
// building randomString - END
// fill image with a white rectangle
imagefill($img, 0, 0, $white);
$string = randomString(rand(7,10));
$_SESSION['string'] = $string;
imagettftext($img, 11, 0, 10, 20, $black, "calibri.ttf", $string);
// fill image with a white rectangle - END
// type of image
header("Content-type: image/png");
imagepng($img);
?>
And this is my code in contact.php:
<?php
session_start();
if(isset($_POST['submit'])) {
if(!empty($_POST['ime']) && !empty($_POST['email']) && !empty($_POST['poruka']) && !empty($_POST['code'])) {
if($_POST['code'] == $_SESSION['rand_code']) {
// send email
$accept = "Poruka uspesno poslata.";
} else {
$error = "Pogresan kod.";
}
} else {
$error = "Molimo Vas popunite sva polja.";
}
}
?>
<!DOCTYPE html >
<html >
<head>
<title>Kontaktirajte nas</title>
</head>
<body>
<?php if(!empty($error)) echo '<div class="error">'.$error.'</div>'; ?>
<?php if(!empty($accept)) echo '<div class="accept">'.$accept.'</div>'; ?>
<form method="post">
<p>Ime<input type="text" name="ime" /></p>
<p>Email<input type="text" name="email" /></p>
<p>Poruka<textarea name="poruka" rows=”25” cols=”40”></textarea></p>
<img src="captcha.php"/>
<p>Posalji<input type="text" name="code" /></p>
<p><input type="submit" name="submit" value="Posalji" class="button" /></p>
<p>"IPO" MASARIKOVA br.5, BEOGRAD</p>
</form>
</body>
</html>
In our system we have so far been using Keycloak 3.4.3 and the Script Authenticator authentication provider functionality as part of the browser based authentication. Now, after upgrading to Keycloak ...
In our system we have so far been using Keycloak 3.4.3 and the Script Authenticator authentication provider functionality as part of the browser based authentication. Now, after upgrading to Keycloak ...
I have a list of the simple objects (containing only names) in my model: var list = [{name: "Jane"}, {name: "Mary"}]; Here I display them: <table> <tr data-ng-repeat="pers in list | filter:...
I have a list of the simple objects (containing only names) in my model: var list = [{name: "Jane"}, {name: "Mary"}]; Here I display them: <table> <tr data-ng-repeat="pers in list | filter:...
I have this simple class : class myCustomClass{ foo(value){ //do some stuff } faa(){ //do some stuff $.getJSON( someUrl, function(data) { // how ...
I have this simple class : class myCustomClass{ foo(value){ //do some stuff } faa(){ //do some stuff $.getJSON( someUrl, function(data) { // how ...
I have an Angular app used to track hours worked by the user. When the user adds a new job, they are taken through a wizard, with each page/controller adding a new property to the job object. Once the ...
I have an Angular app used to track hours worked by the user. When the user adds a new job, they are taken through a wizard, with each page/controller adding a new property to the job object. Once the ...