M
mxmex
Épsilon
Tengo este formulario y necesito agregar alguna linea que me detecte la IP del visitante y me la envie junto al formulario.
Que linea podria insertar en que parte del codigo.
Agradezco ayuda.
<!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>Untitled Document</title>
</head>
<body>
<table width="594" border="0" align="center">
<tr>
<td><p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td width="156"> </td>
<td width="428"><?php
/*Formulario de contacto HTML5, PHP Y Bootstraps
Creado por: Render2web
Version: 1.1*/
//Comprobamos que se haya presionado el boton enviar
if(isset($_POST['enviar'])){
//Guardamos en variables los datos enviados
$nombre = $_POST['nombre'];
$email = $_POST['email'];
$telefono = $_POST['telefono'];
$pais = $_POST['pais'];
$estado = $_POST['estado'];
$ciudad = $_POST['ciudad'];
$emailsec = $_POST['emailsec'];
$mensaje = $_POST['mensaje'];
///Validamos del lado del servidor que el nombre y el email no estén vacios
if($nombre == ''){
echo "Informacion";
}
else if($email == ''){
echo "info@lastapatias.com.mx";
}else{
$para = "info@lastapatias.com.mx";//Email al que se enviará
$asunto = "Contacto por Informacion";//Puedes cambiar el asunto del mensaje desde aqui
//Este sería el cuerpo del mensaje
$mensaje = "
<table border='0' cellspacing='3' cellpadding='2'>
<tr>
<td width='30%' align='left' bgcolor='#f0efef'><strong>Nombre:</strong></td>
<td width='80%' align='left'>$nombre</td>
</tr>
<tr>
<td align='left' bgcolor='#f0efef'><strong>E-mail:</strong></td>
<td align='left'>$email</td>
</tr>
<tr>
<td width='30%' align='left' bgcolor='#f0efef'><strong>Teléfono:</strong></td>
<td width='70%' align='left'>$telefono</td>
</tr>
<tr>
<td width='30%' align='left' bgcolor='#f0efef'><strong>Pais:</strong></td>
<td width='70%' align='left'>$pais</td>
</tr>
<tr>
<td width='30%' align='left' bgcolor='#f0efef'><strong>Estado:</strong></td>
<td width='70%' align='left'>$estado</td>
</tr>
<tr>
<td width='30%' align='left' bgcolor='#f0efef'><strong>Ciudad:</strong></td>
<td width='70%' align='left'>$ciudad</td>
</tr>
<tr>
<td width='30%' align='left' bgcolor='#f0efef'><strong>Email Secundario:</strong></td>
<td width='70%' align='left'>$emailsec</td>
</tr>
<tr>
<td align='left' bgcolor='#f0efef'><strong>Comentario:</strong></td>
<td align='left'>$mensaje</td>
</tr>
</table>
";
$link = mysql_connect("localhost","lastapat_usero","contra seña");
mysql_select_db("lastapat_user",$link);
mysql_query("INSERT INTO usuarios (nombre,email,telefono,pais,estado,ciudad,emailsec ,mensaje) VALUES ('".mysql_real_escape_string($_POST['nombre'])."','".mysql_real_escape_string($_POST['email'])."','".mysql_real_escape_string($_POST['telefono'])."','".mysql_real_escape_string($_POST['pais'])."','".mysql_real_escape_string($_POST['estado'])."','".mysql_real_escape_string($_POST['ciudad'])."','".mysql_real_escape_string($_POST['emailsec'])."','".mysql_real_escape_string($_POST['mensaje'])."')",$link);
//Cabeceras del correo
$headers = "From: $nombre <$email>\r\n"; //Quien envia?
$headers .= "X-Mailer: PHP5\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; //
//Comprobamos que los datos enviados a la función MAIL de PHP estén bien y si es correcto enviamos
if(@mail($para, $asunto, $mensaje, $headers)){
echo "Su mensaje se ha enviado correctamente";
echo "<br />";
echo '<a href="../index.html">Regresar a la Pagina Principal</a>';
}else{
echo "Hubo un error en el envío inténtelo más tarde";
}
}
}
?></td>
</tr>
</table>
</body>
</html>
Que linea podria insertar en que parte del codigo.
Agradezco ayuda.
<!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>Untitled Document</title>
</head>
<body>
<table width="594" border="0" align="center">
<tr>
<td><p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td width="156"> </td>
<td width="428"><?php
/*Formulario de contacto HTML5, PHP Y Bootstraps
Creado por: Render2web
Version: 1.1*/
//Comprobamos que se haya presionado el boton enviar
if(isset($_POST['enviar'])){
//Guardamos en variables los datos enviados
$nombre = $_POST['nombre'];
$email = $_POST['email'];
$telefono = $_POST['telefono'];
$pais = $_POST['pais'];
$estado = $_POST['estado'];
$ciudad = $_POST['ciudad'];
$emailsec = $_POST['emailsec'];
$mensaje = $_POST['mensaje'];
///Validamos del lado del servidor que el nombre y el email no estén vacios
if($nombre == ''){
echo "Informacion";
}
else if($email == ''){
echo "info@lastapatias.com.mx";
}else{
$para = "info@lastapatias.com.mx";//Email al que se enviará
$asunto = "Contacto por Informacion";//Puedes cambiar el asunto del mensaje desde aqui
//Este sería el cuerpo del mensaje
$mensaje = "
<table border='0' cellspacing='3' cellpadding='2'>
<tr>
<td width='30%' align='left' bgcolor='#f0efef'><strong>Nombre:</strong></td>
<td width='80%' align='left'>$nombre</td>
</tr>
<tr>
<td align='left' bgcolor='#f0efef'><strong>E-mail:</strong></td>
<td align='left'>$email</td>
</tr>
<tr>
<td width='30%' align='left' bgcolor='#f0efef'><strong>Teléfono:</strong></td>
<td width='70%' align='left'>$telefono</td>
</tr>
<tr>
<td width='30%' align='left' bgcolor='#f0efef'><strong>Pais:</strong></td>
<td width='70%' align='left'>$pais</td>
</tr>
<tr>
<td width='30%' align='left' bgcolor='#f0efef'><strong>Estado:</strong></td>
<td width='70%' align='left'>$estado</td>
</tr>
<tr>
<td width='30%' align='left' bgcolor='#f0efef'><strong>Ciudad:</strong></td>
<td width='70%' align='left'>$ciudad</td>
</tr>
<tr>
<td width='30%' align='left' bgcolor='#f0efef'><strong>Email Secundario:</strong></td>
<td width='70%' align='left'>$emailsec</td>
</tr>
<tr>
<td align='left' bgcolor='#f0efef'><strong>Comentario:</strong></td>
<td align='left'>$mensaje</td>
</tr>
</table>
";
$link = mysql_connect("localhost","lastapat_usero","contra seña");
mysql_select_db("lastapat_user",$link);
mysql_query("INSERT INTO usuarios (nombre,email,telefono,pais,estado,ciudad,emailsec ,mensaje) VALUES ('".mysql_real_escape_string($_POST['nombre'])."','".mysql_real_escape_string($_POST['email'])."','".mysql_real_escape_string($_POST['telefono'])."','".mysql_real_escape_string($_POST['pais'])."','".mysql_real_escape_string($_POST['estado'])."','".mysql_real_escape_string($_POST['ciudad'])."','".mysql_real_escape_string($_POST['emailsec'])."','".mysql_real_escape_string($_POST['mensaje'])."')",$link);
//Cabeceras del correo
$headers = "From: $nombre <$email>\r\n"; //Quien envia?
$headers .= "X-Mailer: PHP5\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; //
//Comprobamos que los datos enviados a la función MAIL de PHP estén bien y si es correcto enviamos
if(@mail($para, $asunto, $mensaje, $headers)){
echo "Su mensaje se ha enviado correctamente";
echo "<br />";
echo '<a href="../index.html">Regresar a la Pagina Principal</a>';
}else{
echo "Hubo un error en el envío inténtelo más tarde";
}
}
}
?></td>
</tr>
</table>
</body>
</html>

