Ver Mensaje Individual
  #4 (permalink)  
Antiguo 16/03/2011, 13:16
Avatar de carlosmderio3
carlosmderio3
 
Fecha de Ingreso: marzo-2011
Ubicación: valencia
Mensajes: 67
Antigüedad: 13 años, 2 meses
Puntos: 0
Respuesta: Problema con send.php

la imagen es de color rojo, la subes en el mismo directorio.
captcha.php usa y crea el codigo, y el fondo es la imagen...
entonces los archivos van todos juntos en el mismo directorio.

el formulario se llama contacto_email.php
al que le puedes cambiar de nombre, sin tener que editar el script

el captcha.php (si lo cambias deberas cambiar el resto del script), asi como:
procesar.php / fondocaptcha.gif / formestilo.css

contacto_email.php
Código PHP:
<?php session_start(); ?> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Formulario de contacto</title>
    <link href="formestilo.css" rel="stylesheet" type="text/css">
</head>
    <body>
        <form name="formulario" action="procesar.php" method="post"> 
Nombre: (obligatorio)<br /> <input name="nombre" type="text" size="60"><br />

Teléfono (obligatorio): <br /> <input name="telefono" type="text" size="60"><br />

email: (obligatorio)<br /> <input name="email" type="text" size="60"><br />

Asunto: (obligatorio)<br /> <input name="asuntow" type="text" size="60"><br />

Comentarios: (obligatorio)<br /><textarea class="texto" name="comentarios" rows="4" cols="70"></textarea>
<br />(obligatorio)<br />
<img src="captcha.php" width="100" height="30"><br />
<input name="tmptxt" type="text" size="12">
<br /><hr />
  <p>Aceptas las condiciones:<br />
    <a href="terminos.php">Lea los Términos y condiciones de:</a> <strong>sitio web</strong></p>
  <p>Si (obligatorio)
    <input name="aceptas" type="checkbox" id="chequea" />
  No podr&aacute; enviar su consulta si no acepta los T&eacute;rminos.<br />
  <br />
  <label>
    <input type="submit" name="button" id="button" value="Enviar">
  </label>
  <br />
  </p>
    </form>
</body>
</html>
captcha.php

Código PHP:
<?php session_start(); 
function 
captcha($length) { 
$pattern "1234567890abcdefghijklmnopqrstuvwxyz"
for(
$i=0;$i<$length;$i++) { 
$key .= $pattern{rand(0,50)}; 

return 
$key



$_SESSION['tmptxt'] = captcha(8); 
$captcha imagecreatefromgif("fondocaptcha.gif"); 
$colText imagecolorallocate($captcha000); 
imagestring($captcha5167$_SESSION['tmptxt'], $colText); 
header("Content-type: image/gif"); 
imagegif($captcha); 
?>
procesar.php

Código PHP:
<?php session_start();
    if (
$_SESSION['tmptxt'] != $_POST['tmptxt']) { 
    echo 
"<script>window.alert('IMAGEN DE SEGURIDAD INVALIDA');</script>;";;
    echo 
"<script>location.href='javascript:history.back()' ;</script>;";
    exit(); 
    }
    if (!(
$_POST['nombre'])){ 
    echo 
"<script>window.alert('COLOQUE SU NOMBRE');</script>;";;
    echo 
"<script>location.href='javascript:history.back()' ;</script>;";
    exit(); 
    }
    if (!(
$_POST['asuntow'])){ 
    echo 
"<script>window.alert('COLOQUE SU NOMBRE');</script>;";;
    echo 
"<script>location.href='javascript:history.back()' ;</script>;";
    exit(); 
    }
    if (!(
$_POST['telefono'])){ 
    echo 
"<script>window.alert('COLOQUE UN NÚMERO DE TELÉFONO DE CONTACTO');</script>;";;
    echo 
"<script>location.href='javascript:history.back()' ;</script>;";
    exit(); 
    }
    if (!(
$_POST['email'])){
    echo 
"<script>window.alert('COLOQUE UN EMAIL DE CONTACTO');</script>;";;
    echo 
"<script>location.href='javascript:history.back()' ;</script>;";
    exit(); 
    } 
    elseif(!
eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$_POST['email'])){
    echo 
"<script>window.alert('COLOQUE UNA DIRECCIÓN DE EMAIL VÁLIDA');</script>;";;
    echo 
"<script>location.href='javascript:history.back()' ;</script>;";
    exit(); 
    }
    if (!(
$_POST['aceptas'])){ 
    echo 
"<script>window.alert('ACEPTE LAS CONDICIONES DE ESTE SITIO');</script>;";;
    echo 
"<script>location.href='javascript:history.back()' ;</script>;";
    exit(); 
    }
    if (!(
$_POST['comentarios'])){ 
    echo 
"<script>window.alert('LO MÁS IMPORTANTE -> INTRODUZCA SU COMENTARIO');</script>;";;
    echo 
"<script>location.href='javascript:history.back()' ;</script>;";
    exit(); 
    }
      
$recipiente "[email protected]"
      
$asunto "Contacto desde la Pagina WEB ";
      
$message .=" *********************************************<br>";
      
$message .=" ********** Contacto desde la Pagina WEB ********* <br>";
      
$message .=" *********************************************<br>";
      
$message .="Nombre: ".$_POST['nombre']."<br>";
      
$message .="Asunto: ".$_POST['asuntow']."<br>";
      
$message .="E-mail: ".$_POST['email']."<br>"
      
$message .="Telefono: ".$_POST['telefono']."<br>";
      
$message .="Comentarios: ".$_POST['comentarios']."<br>";
      
$message .="********************************************** <br>";
      
$message .="********************************************** <br>";
      
$message .="IP: ".$_SERVER['REMOTE_ADDR']."<br>";
      
$message .="FECHA: ".date("d/m/Y")."<br>";
      
$message .="HORA: ".date("h:i:s a")."<br>";
      
$message .=" ********************************************* <br>";
      
$message .=" ************ sitio web ************ <br>";
      
$message .=" *********************************************<br>";
      
$message stripslashes($message);
      
$headers "MIME-Version: 1.0\r\n"
      
$headers .= "Content-type:text/html; charset=iso-8859-1\r\n"
      
$headers .= "From: ".$_POST['email']."\r\n"
      
$headers .= "Repaly-to: $email\r\n"
      
$headers .= "Cc: ".$_POST['email']."\r\n";  
      
mail($recipiente,$asunto,$message,$headers); 
      echo 
"El mensaje se envio correctamente";
      
?>
formestilo.css
Código CSS:
Ver original
  1. body {
  2.     margin: 16px;
  3.     padding: 0;
  4.     font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  5.     font-size: 12px;
  6.     color: #333;
  7. }
  8.  
  9.  
  10. input, textarea, select  {
  11.     float: left;
  12.     font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  13.     font-size: 12px;
  14.     color: #333;
  15.     padding: 2px;
  16.     width: auto;
  17.     margin-bottom: auto;
  18.     font-weight:bold;
  19.     height: auto;
  20. }
  21. label {
  22.     float: left;
  23.     width: 100px;
  24. }
  25. button {
  26.     width: 80px;
  27.     background: #333;
  28.     color: #FFF;
  29.     padding: 3px 8px;
  30. }
  31. form {
  32.     border: solid 1px #CCC;
  33.     background: #efefef;
  34.     padding: 16px;
  35.     width: 450px;
  36. }
  37. texto { font-weight:bold; }
  38. br { clear: both; }
aqui esta el codigo...

si queres te subo el que estoy usando ahora... que esta en marcha.... que es un poco mas complejo pero seguro que te puede servir si es para alguna empresa o negocio/personal.