- Kód: Egész kijelölése
if($_POST['email'] === "") {echo "<h1>Nem írtál semmilyen üzenetet!</h1>"; $error = true; }
:S
if($_POST['email'] === "") {echo "<h1>Nem írtál semmilyen üzenetet!</h1>"; $error = true; }
<?php
session_start();
class captcha {
var $font = 5;
function random($nr) {
$letters="23456789bcdfghjkmnpqrstvwxyz";
while ($i < $nr) {
if($i==rand(0,$nr-1)) {
$text .= substr(strtoupper($letters), mt_rand(0, strlen($letters)-1), 1);
}
else
{
$text .= substr($letters, mt_rand(0, strlen($letters)-1), 1);
}
$i++;
}
return $text;
}
function captcha($width,$height,$nru) {
$text=$this->random($nru);
$image = @imagecreate($width, $height) or die('unable create image!');
$bg_col = imagecolorallocate($image, 240, 240, 240);
$txt_col = imagecolorallocate($image, 0, 0, 0);
$rand_col = imagecolorallocate($image, 151, 139, 254);
imagefill($image, 100, 100, $bg_col);
imagestring($image, $this->font , rand(1, 10), rand(1,10), $text, $txt_col);
imageline($image, rand(0,$width), rand(0,$height), rand(0,$width), rand(0,$height), $rand_col);
for( $i=0; $i<6; $i++ ) {
imagefilledellipse($image, rand(0,$width), rand(0,$height), 1, 1, $rand_col);
}
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
$_SESSION['chapcha_code'] = strtolower($text);
}
}
$width='70';
$height='25';
$nru='5';
$iesire = new captcha($width,$height,$nru);
?><?php
$recipient = "xxx";
$response = "xxx";
if(empty($_POST['name'])) {
echo "Nem adtál be nevet.";
exit;
}
elseif(empty($_POST['email'])) {
echo "Nem írtál be email-címet.";
exit;
}
elseif(empty($_POST['tema'])) {
echo "Nem írtáll be témát!";
exit;
}
elseif(empty($_POST['comments'])) {
echo "Nem írtál be üzenetet.";
exit;
}
elseif(!preg_match('/^[^\s@]+@[a-z0-9\.-]+?\.[a-z]{2,4}$/i', $_POST['email'])) {
echo "\"" . $_POST['email'] .
"\" Nem érvényes email-cím"; }
if(empty($_POST['chapcha_code'])) {
echo "Nem írtál be kódot!";
}
if($_SESSION['chapcha_code'] == $_POST['chapcha_code']) {
echo "Nem jó kódot írtál be" ;
}
else {
$content = "Feladó neve: " . $_POST['name'] . "\n";
$content .= "Válaszcím: " . $_POST['email'] . "\n";
$content .= "Téma: " . $_POST['tema'] . "\n";
$content .= "\n";
$content .= "Üzenet: \n";
$content .= preg_replace('/\r/', '', stripslashes($_POST['comments']));
$nev = $_POST['name'];
$finalSubject = "üzenet ($nev)";
$addlHeaders = 'Reply-To:' . $_POST['email'];
$addlHeaders = 'Reply-To:' . $_POST['email'];
mail($recipient, $finalSubject, $content, $addlHeaders);
$responseURL = "Location: $response";
header($responseURL);
}
?><?php
session_start();
...
if($_SESSION['chapcha_code'] != $_POST['chapcha_code']) {
echo "Nem jó kódot írtál be" ;
}
else
{
...
}
...
?>
Vissza: Segédletek, Tippek, Egyebek
Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 1 vendég