Foros del Web » Programando para Internet » PHP »

Mail Form Sencillo

Estas en el tema de Mail Form Sencillo en el foro de PHP en Foros del Web. Aqui les dejo algo muy sencillo para envio de mails por una pagina de contactos. Código: <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ...
  #1 (permalink)  
Antiguo 12/09/2007, 11:46
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Mail Form Sencillo

Aqui les dejo algo muy sencillo para envio de mails por una pagina de contactos.

Código:
 
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

$para      = "[email protected]";
$asunto    = Encabezado.';

//*** Aca el cuerpo del Mensaje
$mensaje= "<html><head><title>Comentario de Contactenos</title></head><body><br><br>
<font size=5 font=arial>Este comentario ha sido enviado desde www.dominio.com <br><br>Comentario enviado por: </font><br><br>";
$mensaje = $mensaje."<br><br>Nombre:&nbsp;&nbsp;".$_POST['nombre']; 
$mensaje = $mensaje."<br><br>Correo Electronico:&nbsp;&nbsp;<a href='mailto:".$_POST['correo']."'>".  $_POST['correo']     ."</a>"; 
$mensaje = $mensaje."<br><br>Telefono:&nbsp;&nbsp;".$_POST['telefono'];
$mensaje = $mensaje."<br><br>Direccion:&nbsp;&nbsp;".$_POST['direccion']; 
$mensaje = $mensaje."<br><br>Comentario:&nbsp;&nbsp;".$_POST['comentario']; 
$mensaje = $mensaje."<br><br></body></html>";

//***************************************************************
$cabeceras =  'From:'. $correo . "\r\n";
$cabeceras .= 'Reply-To: [email protected]' . "\r\n";
$cabeceras .= "Content-type: text/html; charset=iso-8859-1\n";
mail($para, $asunto, $mensaje, $cabeceras);
//***********************************************************************

  $insertGoTo = "final.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}


?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../css/estilo.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>
<link href="css/ccs-txt.css" rel="stylesheet" type="text/css">
<link href="css/estilo.css" rel="stylesheet" type="text/css">
<link href="estilos.css" rel="stylesheet" type="text/css">
</head>

<body>
<form action="form.php" method="post" name="form1" onSubmit="MM_validateForm('nombre','','R','correo','','RisEmail','telefono','','NisNum');return document.MM_returnValue">
  <table align="center">
    <tr valign="baseline">
      <td align="right" nowrap class="verdana_once">*Nombre:</td>
      <td width="170" class="verdana_once"><input name="nombre" type="text" id="nombre" style="font-family: Verdana; color: #7a7864; font-size: 8pt; font-weight: regular; border: 1px solid #94906D" onBlur="MM_validateForm('nombre','','R');return document.MM_returnValue" value="" size="34"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap class="verdana_once">*E-Mail:</td>
      <td class="verdana_once"><input name="correo" type="text" style="font-family: Verdana; color: #7a7864; font-size: 8pt; font-weight: regular; border: 1px solid #94906D" onBlur="MM_validateForm('correo','','RisEmail');return document.MM_returnValue" value="" size="34"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap class="verdana_once">Tel&eacute;fono:</td>
      <td class="verdana_once"><input type="text" name="telefono" value="" size="34" style="font-family: Verdana; color: #7a7864; font-size: 8pt; font-weight: regular; border: 1px solid #94906D"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap class="verdana_once">Empresa: </td>
      <td class="verdana_once"><input type="text" name="direccion" value="" size="34" style="font-family: Verdana; color: #7a7864; font-size: 8pt; font-weight: regular; border: 1px solid #94906D"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" valign="top" nowrap class="verdana_once">*Comentarios</td>
      <td class="verdana_once">
      <textarea name="comentario" cols="31" rows="5" style="font-family: Verdana; color: #7a7864; font-size: 8pt; font-weight: regular; border: 1px solid #94906D"></textarea>      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td class="verdana_once"><div align="right">
        <input type="submit" class="verdana11" style="font-family: Verdana; color: #7a7864; font-size: 8pt; font-weight: bold; border: 1px solid #7a7864" value="Enviar">
      </div></td>
    </tr>
  </table>
  <p class="texto-normal">
    <input type="hidden" name="MM_insert" value="form1">
  </p>
</form>
</body>
</html>
  #2 (permalink)  
Antiguo 12/09/2007, 12:18
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Re: Mail Form Sencillo

En los FAQs del foro podras encontrar codigos similares.

Tema cerrado.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Tema Cerrado




La zona horaria es GMT -6. Ahora son las 11:35.