Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/01/2010, 14:46
Avatar de SDEK
SDEK
 
Fecha de Ingreso: diciembre-2009
Ubicación: MX
Mensajes: 156
Antigüedad: 14 años, 3 meses
Puntos: 8
Respuesta: Hacer Comentarios!

Cita:
Iniciado por edGarzitho Ver Mensaje
Hola amigos, aqui ando de nuevo buscando ayuda. esta vez necesito poner un sistema de comentarios sugerencias, pero que los comentarios que el usuario aga se envien a mi correo, algo asi mas o menos como el que se encuentra alojado en esta web. espero me puedan ayudar porfavor!

http://www.muchografico.com/sugerencias.php

Hola,

Te dejo dos archivos, contact.php y thanks.php. El primero es el formulario y al hacer "submit" envia la información al 2do archivo, este a su vez lo envía al correo electronico que tu elijas pasando como parametro a las variables el valor de los campos del formulario.

contact.php

Código:
<?
if(!isset($_SERVER['HTTP_USER_AGENT'])){
   die("Forbidden - You are not authorized to view this page");
   exit;
} 
if(!$_SERVER['REQUEST_METHOD'] == "POST"){
   die("Forbidden - You are not authorized to view this page");
   exit;    
} 
$httprefe = getenv ("HTTP_REFERER");
$httpagente = getenv ("HTTP_USER_AGENT");
$datee = date("d/m/Y H:i:s");
?>
<!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=utf-8" />
<title>Titulo web</title>


</head>

<body>


               <form method="post" onsubmit="return validar(this)" id="form1" action="thanks.php">
                              

<div><input type="hidden" name="token" value="<?=$token?>" /><input type="hidden" name="ip" value="<?=$_SERVER['REMOTE_ADDR']?>" />
                      <!-- Si desea comunicarse con nosotros, por favor llene este formulario.--></div><p/>
       
<div><input type="hidden" name="httpref" value="<?=$httprefe?>" /><img height="1" src="imagenes/spacer.gif" width="1" /></div>

<div><input type="hidden" name="httpagent" value="<?=$httpagente?>" /></div>
                        </p><div>Nombre * </div>
    <input type="hidden" name="date" value="<?=$datee?>" />

	<div><input name="name" class="FormInput" id="name" size="45" maxlength="200" /></div>
     

		<div>Organizaci&oacute;n</div>
                        <div><input name="empresa" class="FormInput" id="empresa" size="45" maxlength="200" /></div>
        

  		<div>E-Mail *</div>
		<div><input name="email" class="FormInput" id="email" size="45" maxlength="200" /></div>

                        <div>Tel / Fax </div>
                        <div><input name="phone" class="FormInput" id="phone" size="45" maxlength="200" /></div>
                        <div>Mensaje  * </div>
                        <div><textarea class="FormInput" id="message" name="message" rows="4" cols="34"></textarea></div>
                        
                                               
<div></div>
           <div style="float:right; margin-right:15px;"><input type="submit" value="Enviar"  /></div>
                </form>

</body>
</html>
thanks.php

Código:
<?
  @import_request_variables("gpc");
    $youremail = "[email protected]"; //Tu correo debe ir aquí 
    $subject = "Contenido del formulario: "; // Titulo con el que recibiras el cotenido del formulario
    $redirect = "contact.php";//URL en a la que redirigira
    $secs = "5";// tiempo en el que será redirigido

if(eregi("MIME-Version:",$postVars)) {
mail("[email protected]"/* Tu correo debe ir aquí */, "Form Hijack Attempt", "A spam relay was attempted from the Web site and was blocked.", "From:SpamMonitor");
die();
} //BLOCKING spam


 $secret = 'ssshhitsasecret';  
    $token = md5(rand(1, 1000).$secret);
    $_SESSION['token'] = $token;
    ?> 
<!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=utf-8" />
<title>Titulo web</title>

</head>

<body>

<?
  //a partir de aquí hay una serie de variables que impiden que los spammers usen nuestro formulario como lanzadera de su spam 
  $name = stripslashes($name);
  $message = stripslashes($message);
  $headers .= "From: " . $email . "\r\n\r\n"; 
    //This is where the email is sent using your values from above. Be sure to update this if you change any fields in contact.php
mail("$youremail", "$subject","
    Name: $name
    Empresa: $empresa
    Email: $email
    Telefono: $phone
    Direccion: $direccion
    Message: $message 
    IP: $ip
    Date : $date
",$headers);
   // Strip \r and \n from the email address
   $_POST['email'] = preg_replace("\r", "", $_POST['email']);
   $_POST['email'] = preg_replace("\n", "", $_POST['email']);

//*****COMMENT: Si tienes problemas con las lineas 45/46, reemplaza por:
//$_POST['email'] = str_replace("\r", "", $_POST['email']);
//$_POST['email'] = str_replace("\n", "", $_POST['email']);//*****

   $_SESSION['token'] = $token; 
   $token = md5(rand(1, 1000).$secret);
   $secret = 'ssshhitsasecret';
   $field = preg_replace( "/[\n\r]+/", " ", $field );
    // Remove injected headers
    $find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i");
    $_POST['email'] = preg_replace($find, "", $_POST['email']);
    $message = preg_replace($find, "", message); 
    $email=str_replace("\r","\n",$email);
    $name=str_replace("\r","\n",$name);
    $message=str_replace("\r","\n",$message);
    $phone=str_replace("\r","\n",$phone);
	$empresa=str_replace("\r","\n",$empresa);
	$direccion=str_replace("\r","\n",$direccion);
   
  
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
ob_clean();
mail("$youremail", "Message Killed", "$message", "From: $name <$email>");
exit("Message killed.");
}
 if (eregi('^(bcc$|content-type|mime-version|--)',$key))
print_error("Field names indicate exploit."); //BLOCKING SPAM

?>


<div>
<!-- division form -->
Gracias por enviar su mensaje, en breve lo contactaremos!
</div>




</body>
</html>
Saludos, espero que te sea útil.

--------------------
SDEK
Desarrollo WEB