Antispam code not working

Hi guys,
I’m new to this forum and not sure this is the correct section to post this question.
Anyway…
I’m trying to create a contact form with an anti spam check. I don’t know why the output result of the php code for the anti spam is a small question mark as the one shown for missing images. Underneath the code I used.

Thank to everyone who can help me out :wink:

Cheers,
Lorenzo

      • html

[php]

code[/b] Autorizzo il trattamento dei dati Accetto la Privacy Policy [/php]
      • php spam.php
        [php] <?

$_SESSION[“code”] = rand(11111, 99999);

header(“Content-type: image/png”);
$im = @imagecreate(55, 20)
or die(“Cannot Initialize new GD image stream”);
$background_color = imagecolorallocate($im, 0, 102, 153);
$text_color = imagecolorallocate($im, 255, 255, 255);
$line_color = imagecolorallocate($im, 0, 153, 0);
$line2_color = imagecolorallocate($im, 255, 0, 0);
imageline($im, 0, 5, 55, 5, $line_color);
imageline($im, 0, 10, 55, 10, $line_color);
imageline($im, 0, 15, 55, 15, $line_color);

imageline($im, 5, 0, 5, 55, $line2_color);
imageline($im, 15, 0, 15, 55, $line2_color);
imageline($im, 25, 0, 25, 55, $line2_color);
imageline($im, 35, 0, 35, 55, $line2_color);
imageline($im, 45, 0, 45, 55, $line2_color);

imagestring($im, 8, 5, 2, $_SESSION[“code”], $text_color);

imagepng($im);
imagedestroy($im);
?>
[/php]

First thing, is to not use short tags for the PHP code. They are sometimes enabled, but a bad idea to use anyway.

<? vs <?php You shouldn't be using tables for layout either. CSS has come a long way since whatever you are using to learn was done. [php]$im = @imagecreate(55, 20)[/php] You also don't want to hide errors and exceptions. That is what the "@" is doing in front of the imagecreate function.
Sponsor our Newsletter | Privacy Policy | Terms of Service