Google Búsqueda personalizada

Regístrate gratis para participar de los foros, o si ya estás registrado haz login.

consulta por formulario con captcha

comentario del autor Jue Sep 03, 2009 2:47 pm
   
hola a todos ,primero que nada les comento que se muy poco de programacion y estoy haciendo un formulario con captcha con el programa WYSIWYG Web Builder , si bien se crea todo no me funciona , mi consulta es si me pueden ayudar en esto, les comento los aechivos que tengo son una carpeta que dice images, archivo que dice captcha1.php y index.html .si bien adjunto los archivos dejo el codigo para que los vean.

index.html:
<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (isset($_POST['captcha_code'],$_SESSION['random_txt']) && md5($_POST['captcha_code']) == $_SESSION['random_txt'])
{
unset($_POST['captcha_code'],$_SESSION['random_txt']);
}
else
{
echo '<b>The entered code was wrong.</b><br>';
echo '<a href="javascript:history.back()">Go Back</a>';
exit;
}
}
?>
<?php
function ValidateEmail($email)
{
$pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
return preg_match($pattern, $email);
}

if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$mailto = 'pongoaqui@midominio.com.ar';
$mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
$subject = 'Contact Information prueba';
$message = 'Values submitted from web site form:';
$success_url = '';
$error_url = '';
$error = '';
$eol = "\n";
$max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000;
$boundary = md5(uniqid(time()));

$header = 'From: '.$mailfrom.$eol;
$header .= 'Reply-To: '.$mailfrom.$eol;
$header .= 'MIME-Version: 1.0'.$eol;
$header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
$header .= 'X-Mailer: PHP v'.phpversion().$eol;
if (!ValidateEmail($mailfrom))
{
$error .= "The specified email address is invalid!\n<br>";
}

if (!empty($error))
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $error, $errorcode);
echo $errorcode;
exit;
}

$internalfields = array ("submit", "reset", "send", "captcha_code");
$message .= $eol;
foreach ($_POST as $key => $value)
{
if (!in_array(strtolower($key), $internalfields))
{
if (!is_array($value))
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
}
else
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
}
}
}

$body = 'This is a multi-part message in MIME format.'.$eol.$eol;
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: text/plain; charset=iso-8859-1'.$eol;
$body .= 'Content-Transfer-Encoding: 8bit'.$eol;
$body .= $eol.stripslashes($message).$eol;
if (!empty($_FILES))
{
foreach ($_FILES as $key => $value)
{
if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $max_filesize)
{
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
$body .= 'Content-Transfer-Encoding: base64'.$eol;
$body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
$body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
}
}
}
$body .= '--'.$boundary.'--'.$eol;
mail($mailto, $subject, $body, $header);
header('Location: '.$success_url);
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled Page</title>
<meta name="generator" content="WYSIWYG Web Builder - http://www.wysiwygwebbuilder.com">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="wb_Form1" style="position:absolute;left:95px;top:102px;width:345px;height:267px;z-index:6;" align="left">
<form name="contact" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" id="Form1">
<div id="wb_Text1" style="position:absolute;left:10px;top:15px;width:35px;height:14px;z-index:0;" align="left">
<font style="font-size:11px" color="#000000" face="Arial">Name:</font></div>
<input type="text" id="Editbox1" style="position:absolute;left:55px;top:15px;width:200px;font-family:Courier New;font-size:16px;z-index:1" name="nombre" value="">
<div id="wb_Text2" style="position:absolute;left:10px;top:44px;width:35px;height:14px;z-index:2;" align="left">
<font style="font-size:11px" color="#000000" face="Arial">Email:</font></div>
<input type="text" id="Editbox2" style="position:absolute;left:55px;top:44px;width:200px;font-family:Courier New;font-size:16px;z-index:3" name="email" value="">
<input type="submit" id="Button1" name="Button1" value="Send" style="position:absolute;left:59px;top:187px;width:96px;height:25px;font-family:Arial;font-size:13px;z-index:4">
<div id="wb_Captcha1" style="position:absolute;left:50px;top:97px;width:202px;height:38px;z-index:5;" align="left">
<img src="captcha1.php" alt="Click for new image" title="Click for new image" style="cursor:pointer;width:100px;height:38px;" onclick="this.src='captcha1.php?'+Math.random()">
<input type="text" id="Captcha1Edit" style="position:absolute;left:105px;top:14px;width:102px;font-family:Courier New;font-size:16px;" name="captcha_code" value=""></div>
</form>
</div>
</body>
</html>

.................................
archivo captcha.php:

<?php
$width = 100;
$height = 38;
$font = 'verdana.ttf';
$f_size = 12;
$bg_color = array(240, 240, 240);
$chars = 'ABCDEFGHKMNPQRSTUVWXYZ23456789';
session_start();
putenv('GDFONTPATH=' . realpath('.'));
$img = imagecreatetruecolor($width, $height);
$bkgr = imagecolorallocate($img, $bg_color[0], $bg_color[1], $bg_color[2]);
imagefilledrectangle($img, 0, 0, $width, $height, $bkgr);
$code = '';
for($i = 0; $i < 5; $i++)
{
$code .= $chr = $chars[mt_rand(0, strlen($chars)-1)];
imagettftext($img, $f_size, mt_rand(-35,35), 5+$i*(4/3*$f_size+2), mt_rand(4/3*$f_size, $height-(4/3*$f_size)/2), imagecolorallocate($img, mt_rand(0,192), mt_rand(0,192), mt_rand(0,192)), $font, $chr);
}
$_SESSION['random_txt'] = md5($code);
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?>
..............................

les agradeceria la ayuda.

prueba.rar  (88.78 kb) -

piratapepe

Reputación



Hacer una pregunta

Boletín de Noticias

Reciba noticias de tecnología, tips de reparación y ofertas exclusivas.



Reglamento / P+F

Foros

Miembros / Expertos