|
|
||||||
|
|
|
|
|
|
|
|
|
|
#1 |
|
Junior
Registrado: August-2007
Location: zgh49M
Posts: 1
|
problema con formulario php
hola.
tengo un problema con un formulario php. El formulario base funciona bien, pero quisiera agregarle un input SELECT para la fecha de nacimiento (dia, mes, año, con opciones preestablecidas). Ese es el problema. No se como puedo hacer para que el php valide y procese ese SELECT. Otra cosa, el textarea Movil debe aceptar solo numeros y no letras. Alguien sabe como programar eso? Denme una mano Gracias Aqui les paso mi php ---------------------------------------------------------------------------------------------------------- <?php if (isset($_POST["op"]) && ($_POST["op"]=="send")) { /******** START OF CONFIG SECTION *******/ $sendto = "mm@mm.com"; $subject = "Mmm"; // Select if you want to check form for standard spam text $SpamCheck = "Y"; // Y or N $SpamReplaceText = "*content removed*"; // Error message prited if spam form attack found $SpamErrorMessage = "<p align=\"center\"><font face=\"verdana,arial,helvetica,sans-serif\" size=\"1\"><font color=\"white\">Se ha detectado codigo malicioso. </font><br><b>Tu numero de IP <b>".getenv("REMOTE_ADDR")."</b> se ha descartado.</b></p>"; /******** END OF CONFIG SECTION *******/ $nombre = $HTTP_POST_VARS['nombre']; $fijo = $HTTP_POST_VARS['fijo']; $movil = $HTTP_POST_VARS['movil']; $email = $HTTP_POST_VARS['email']; $mensaje = $HTTP_POST_VARS['mensaje']; $headers = "From: $email\n"; $headers . "MIME-Version: 1.0\n" . "Content-Transfer-Encoding: 7bit\n" . "Content-type: text/html; charset = \"iso-8859-1\";\n\n"; if ($SpamCheck == "Y") { // Check for Website URL's in the form input boxes as if we block website URLs from the form, // then this will stop the spammers wastignt ime sending emails if (preg_match("/http/i", "$nombre")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$fijo")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$movil")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$mensaje")) {echo "$SpamErrorMessage"; exit();} // Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer $pattern = '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'; // build the pattern match string $nombre = preg_replace($pattern, "", $nombre); $fijo = preg_replace($pattern, "", $fijo); $movil = preg_replace($pattern, "", $movil); $email = preg_replace($pattern, "", $email); $mensaje = preg_replace($pattern, "", $mensaje); // Check for the injected headers from the spammer attempt // This will replace the injection attempt text with the string you have set in the above config section $find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i"); $email = preg_replace($find, "$SpamReplaceText", $email); $nombre = preg_replace($find, "$SpamReplaceText", $nombre); $fijo = preg_replace($find, "$SpamReplaceText", $fijo); $movil = preg_replace($find, "$SpamReplaceText", $movil); $mensaje = preg_replace($find, "$SpamReplaceText", $mensaje); // Check to see if the fields contain any content we want to ban if(stristr($nombre, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($mensaje, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($fijo, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($movil, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} // Do a check on the send email and subject text if(stristr($sendto, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($subject, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} } // Build the email body text $emailcontent = " MMM Ha recibido un mensaje desde el sitio web La ruta indica mensaje desde el formulario CONTACTO. Nombre: $nombre Telefono Fijo: $fijo Telefono Movil: $movil Email: $email Mensaje: $mensaje _______________________ "; // Check the email address entered matches the standard email address format if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)) { echo "<p align=\"center\"><font face=\"verdana,arial,helvetica,sans-serif\" size=\"1\"><font color=\"white\">Su correo electrónico no es válido</p><p align=\"center\"><font face=\"verdana,arial,helvetica,sans-serif\" size=\"1\"><font color=\"white\">Click <a href='javascript: history.go(-1)'>aquí</a> para regresar y corregir el error.</p>"; } elseif (!trim($nombre)) { echo "<p align=\"center\"><font face=\"verdana,arial,helvetica,sans-serif\" size=\"1\"><font color=\"white\">Por favor, ingrese su nombre</p><p align=\"center\"><font face=\"verdana,arial,helvetica,sans-serif\" size=\"1\"><font color=\"white\">Click <a href='javascript: history.go(-1)'>aquí</a> para regresar y corregir el error.</p>"; } elseif (!trim($mensaje)) { echo "<p align=\"center\"><font face=\"verdana,arial,helvetica,sans-serif\" size=\"1\"><font color=\"white\">Por favor, ingrese el mensaje</p><p align=\"center\"><font face=\"verdana,arial,helvetica,sans-serif\" size=\"1\"><font color=\"white\">Click <a href='javascript: history.go(-1)'>aquí</a> para regresar y corregir el error.</p>"; } elseif (!trim($email)) { echo "<p align=\"center\"><font face=\"verdana,arial,helvetica,sans-serif\" size=\"1\"><font color=\"white\">Por favor, ingrese su correo electrónico</p><p align=\"center\"><font face=\"verdana,arial,helvetica,sans-serif\" size=\"1\"><font color=\"white\">Click <a href='javascript: history.go(-1)'>aquí</a> para regresar y corregir el error.</p>"; } // Sends out the email or will output the error message elseif (mail($sendto, $subject, $emailcontent, $headers)) { echo "<br><br><p align=\"center\"><font face=\"verdana,arial,helvetica,sans-serif\" size=\"1\"><font color=\"white\"><b>Muchas gracias, $nombre</b></p><p align=\"center\"><font face=\"verdana,arial,helvetica,sans-serif\" size=\"1\"><font color=\"white\">Pronto nos pondremos en contacto con Ud.</p>"; } } else { ?> <form method="post"> |
|
|
|
![]() |
| > problema con formulario php |
| Herramientas | |
| Estilo | |
|
|