<?php function mailing() { $imie = $_POST['imie']; $email = $_POST['mail']; $telefon = $_POST['telefon']; $temat = $_POST['temat']; $wiadomosc = $_POST['wiadomosc']; $captcha = $_POST['captcha']; $message = "<p>Imię i nazwisko: ".$imie."</p> <br>". "<p>Adres e-mail: ".$email."</p>". "<p>Temat wiadomości: ".$temat."</p>". "<p>Treść wiadomości: ".$wiadomosc."</p>"; $headers = "From: $email \n"; $headers .= "MINE-Version: 1.0\n"; $headers .= "Contact-Type: text/html; charset=UTF-8\n"; $widok = "<div id='podziekowanie'>Wiadomość została wysłana!<br> Dziękujemy. Postaramy się odpowiedzieć najszybciej, jak to tylko możliwe. <br><br> Za 5 sekund nastąpi przekierowanie na stronę główną. Prosimy czekać. </div>" ; return $widok; }; function form($pola=false) { return $form = '<div id="formularz"> <form method="post" action="kontakt.php"> <div> <label for = "imie">Imię i nazwisko * </label> <input type="text" value = "'.$pola['imie'].'" name="imie" required placeholder="Wpisz imię i nazwisko"> </div> <br /> <div> <label for = "mail">Adres e-mail *</label> <input type="text" value = "'.$pola['mail'].'" name="mail" required placeholder="Twój Adres E-Mail"> <br> </div> <br /> <div> <label for = "telefon">Telefon *</label> <input type="text" value = "'.$pola['telefon'].'" name="telefon" required placeholder="Podaj swój numer telefonu"> <br> </div> <br /> <div> <label for = "temat">Temat *</label> <input type="text" value = "'.$pola['temat'].'" name="temat" required placeholder="Nazwa Tematu"><br> </div> <br /> <div> <label for = "wiadomosc">Zapytanie *</label> <textarea name="wiadomosc" required placeholder="Wiadomość...">'.$pola['wiadomosc'].' </textarea> <br> </div> <br /><br /> <div id="captcha"> <label for = "wiadomosc">Captcha *</label> <img src="image.php"> <br> <input type="text" value = "'.$pola['captcha'].'" name="captcha" required placeholder="Przepisz kod z obrazka..."><br> </div> <br /> <div> <br> <input type="reset" value="Wyczyść"> <input type="submit" value="Wyślij"> </div> </form> </div>'; } if ($_POST){ $image = $_POST['image']; } } } } } else if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9]+)*@[a-z0-9]+(\.[a-z0-9]+)*(\.[a-z]{2,4})$", $_POST['mail'])) { } } else if($_POST['captcha'] != $image) { } else if($image == $_SESSION['string']) { } ?>
Problem polega na tym, że kod wysyła formularz zawsze pomimo złego kodu captcha. Próbowałem na kilka sposobów i nic mi nie wychodzi. Podsyłam jeszcze plik image.php
<?php $img = imagecreatetruecolor(150,40); $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); function randomString($length){ $chars = "abcdefghijkmnopqrstuvwxyz023456789"; $str = ""; $i = 0; while($i <= $length){ $str = $str . $tmp; $i++; } return $str; } } imagefill($img, 0, 0, $white); $_SESSION['string'] = $string; imagettftext($img, 18, 0, 10, 20, $black, "Arial.ttf", $string); imagepng($img); imagedestroy($img); ?>