Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/09/2010, 22:11
fabayan
 
Fecha de Ingreso: septiembre-2009
Mensajes: 87
Antigüedad: 14 años, 7 meses
Puntos: 1
Enviar mail con ip en acceso a página

Buenas: necesito validar un autoenvio de ip cuando se accede a una determinada pagina. El script sólo funciona:


Código PHP:
<?php 
    
// Predefinimos las variables a usar 
    
$nombre        'Pone tu nombre aqui'
    
$destinatario    "[email protected]"
    
$asunto        "Visita nueva el ".date("D, d M Y - h:i:s a "); 
    
$remote_ip    = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : "(Sin IP)"
    
$remote_isp    gethostbyaddr($remote_ip); 
    
$agent        $_SERVER['HTTP_USER_AGENT']; 
    
$referer        = (isset($_SERVER['HTTP_REFERER'])) ? strtolower($_SERVER['HTTP_REFERER']) : "Sin referido"
    
$headers        'From: '.$nombre.'<'.$destinatario.'>'."\r\n"
    
// Armamos el cuerpo del mensaje 
    
$msg "-------------------------------------------- \n"
    
$msg.= "         Informacion de visitante            \n"
    
$msg.= "-------------------------------------------- \n"
    
$msg.= "PAGINA:     ".$_SERVER['PHP_SELF']."\n"
    
$msg.= "HORA:       ".date("h:i:s a ")."\n"
    
$msg.= "FECHA:      ".date("D, d M Y")."\n"
    
$msg.= "NAVEGADOR:  ".$agent."\n"
    
$msg.= "IP/ISP:     ".$remote_ip." (".$remote_isp.")"."\n"
    
$msg.= "REFERIDO:   ".$referer."\n"
    
$msg.= "------------------------------------------ \n\n"
    
// Finalmente enviamos el correo 
    
mail($destinatario$asunto$msg$headers
?>
Pero cuando trato de agregarle una validación para que si apretan 60 veces F5 no me mande 60 mails,


Código PHP:
<?php
session_start
();
if(!isset(
$_SESSION['visita'])) {

    
// Predefinimos las variables a usar
    
$nombre        'Visita inesperada';
    
$destinatario    "[email protected]";
    
$asunto        "Visita nueva el ".date("D, d M Y - h:i:s a ");
    
$remote_ip    = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : "(Sin IP)";
    
$remote_isp    gethostbyaddr($remote_ip);
    
$agent        $_SERVER['HTTP_USER_AGENT'];
    
$referer        = (isset($_SERVER['HTTP_REFERER'])) ? strtolower($_SERVER['HTTP_REFERER']) : "Sin referido";
    
$headers        'From: '.$nombre.'<'.$destinatario.'>'."\r\n";
    
// Armamos el cuerpo del mensaje
    
$msg "-------------------------------------------- \n";
    
$msg.= "         Informacion de visitante            \n";
    
$msg.= "-------------------------------------------- \n";
    
$msg.= "PAGINA:     ".$_SERVER['PHP_SELF']."\n";
    
$msg.= "HORA:       ".date("h:i:s a ")."\n";
    
$msg.= "FECHA:      ".date("D, d M Y")."\n";
    
$msg.= "NAVEGADOR:  ".$agent."\n";
    
$msg.= "IP/ISP:     ".$remote_ip." (".$remote_isp.")"."\n";
    
$msg.= "REFERIDO:   ".$referer."\n";
    
$msg.= "------------------------------------------ \n\n";
    
// Finalmente enviamos el correo
    
mail($destinatario$asunto$msg$headers)

  
$_SESSION['visita'] = 1;

?>
Me aparece el siguiente error: Parse error: parse error in C:\wamp\www\i\index.php on line 28

Alguien me puede echar una mano...

Gracias totales

Última edición por jpinedo; 15/09/2010 a las 23:06