Foros del Web » Programando para Internet » PHP »

Formulario de contacto

Estas en el tema de Formulario de contacto en el foro de PHP en Foros del Web. Alguien sabe decirme si hay algo mal en este codigo? !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" ...
  #1 (permalink)  
Antiguo 09/01/2011, 13:50
Avatar de fernando2222  
Fecha de Ingreso: diciembre-2009
Mensajes: 110
Antigüedad: 14 años, 4 meses
Puntos: 1
Formulario de contacto

Alguien sabe decirme si hay algo mal en este codigo?

!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>contactoht</title>
<script 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_valida teForm.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>
<style type="text/css">
<!--
body {
background-color: #999999;
}
-->
</style></head>

<body>
<form action="contact.php" method="POST" onsubmit="MM_validateForm('EmailFrom','','RisEmail ');MM_validateForm('Nombre','','R');MM_validateFor m('consulta','','R');return document.MM_returnValue">
<p>Email:<br>
<input type="text" name="EmailFrom">
<p>Nombre:<br>
<input type="text" name="Nombre">
<p>Apellido (opcional) <br>
<input type="text" name="Name">
<p>consulta:<br>
<textarea name="consulta" cols="30" rows="10"></textarea>
<p>

<p>
<input type="submit" name="submit" value="Enviar" />

</form>
<p>

<!-- Contact Form credit link -->

</body>
</html>

Y aqui va el de php


<?php
// Website Contact Form Generator
// http://www.tele-pro.co.uk/scripts/contact_form/
// This script is free to use as long as you
// retain the credit link

// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['e-mail']));
$EmailTo = "[email protected]";
$Subject = "consulta uno";
$Nombre = Trim(stripslashes($_POST['Nombre']));
$Apellido= Trim(stripslashes($_POST['Apellido']));
$consulta = Trim(stripslashes($_POST['consulta']));

// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}

// prepare email body text
$Body = "";
$Body .= "Nombre: ";
$Body .= $Nombre;
$Body .= "\n";
$Body .= "Apellido: ";
$Body .= $Apellido;
$Body .= "\n";
$Body .= "consulta: ";
$Body .= $consulta;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
__________________
__________________
www.mshunderwear.com.ar la marca del momento....
  #2 (permalink)  
Antiguo 09/01/2011, 13:55
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Desacuerdo Respuesta: Formulario de contacto

Cita:
Iniciado por fernando2222 Ver Mensaje
Alguien sabe decirme si hay algo mal en este codigo?
hmmm...

¿de verdad esperas que leamos todo el código solo para decirte que anda mal?

¿se te ocurrió tal ves usar [php][/php] o [highlight=PHP][/highlight] para resaltar mejor tu código?

¿ya ejecutaste tu código y recibes algún error o algo?

vamos amigo... que en el foro se trata de ayudar, no de leer códigos que vagos no se atreven a leer... ¿y luego para que? ¿esperas que alguien te diga "si esta mal ahí, y ahí", que te de el código corregido y bendito sea el señor?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 09/01/2011, 15:20
Avatar de fernando2222  
Fecha de Ingreso: diciembre-2009
Mensajes: 110
Antigüedad: 14 años, 4 meses
Puntos: 1
Respuesta: Formulario de contacto

Yá está en el sitio funcionando, pero no envía los mensajes
__________________
www.mshunderwear.com.ar la marca del momento....

Etiquetas: contacto, formulario
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.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:14.