zaiber Posted September 1, 2009 Share Posted September 1, 2009 I need to know what I need to use on my verify.php form to show the values after clicking on the submit button, I am using some javascripts to validate some values: ************************** Javascript section <script type="text/javascript"> function validateFormOnSubmit(theForm) { var reason = ""; reason += validateUsername(theForm.username); reason += validateEmail(theForm.email); reason += validatePhone(theForm.phone); reason += validatePhone2(theForm.phone2); if (reason != "") { alert("Some fields need correction:\n" + reason); return false; } return true; } </script> <script type="text/javascript"> function validateEmpty(fld) { var error = ""; if (fld.value.length == 0) { fld.style.background = 'Yellow'; error = "Algunos campos no han sido llenados.\n" } else { fld.style.background = 'White'; } return error; } </script> <script type="text/javascript"> function validateUsername(fld) { var error = ""; var illegalChars = /\W/; // allow letters, numbers, and underscores if (fld.value == "") { fld.style.background = 'Yellow'; error = "Ingrese por favor su NOMBRE.\n"; } else if ((fld.value.length < 1) || (fld.value.length > 20)) { fld.style.background = 'Yellow'; error = "The username is the wrong length.\n"; } else if (illegalChars.test(fld.value)) { fld.style.background = 'Yellow'; error = "Su Nombre contiene caracteres que no son letras.\n"; } else { fld.style.background = 'White'; } return error; } </script> <script type="text/javascript"> function trim(s) { return s.replace(/^\s+|\s+$/, ''); } function validateEmail(fld) { var error=""; var tfld = trim(fld.value); // value of field with whitespace trimmed off var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ; var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ; if (fld.value == "") { fld.style.background = 'Yellow'; error = "No ha ingresado su CORREO ELECTRONICO.\n"; } else if (!emailFilter.test(tfld)) { //test email for illegal characters fld.style.background = 'Yellow'; error = "Ingrese un CORREO ELECTRONICO válido.\n"; } else if (fld.value.match(illegalChars)) { fld.style.background = 'Yellow'; error = "Su CORREO ELECTRONICO contiene caracteres que no son válidos.\n"; } else { fld.style.background = 'White'; } return error; } </script> <script type="text/javascript"> function validatePhone(fld) { var error = ""; var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, ''); if (fld.value == "") { error = "No ingreso su codigo LADA.\n"; fld.style.background = 'Yellow'; } else if (isNaN(parseInt(stripped))) { error = "El campo LADA contiene caracteres que no son números.\n"; fld.style.background = 'Yellow'; } else if (!(stripped.length == 3)) { error = "Favor de ingresar su codigo LADA (3 digitos en total).\n"; fld.style.background = 'Yellow'; } return error; } </script> <script type="text/javascript"> function validatePhone2(fld) { var error = ""; var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, ''); if (fld.value == "") { error = "No ingreso su TELEFONO.\n"; fld.style.background = 'Yellow'; } else if (isNaN(parseInt(stripped))) { error = "El campo TELEFONO contiene caracteres que no son números.\n"; fld.style.background = 'Yellow'; } else if (!(stripped.length == 7)) { error = "Favor de ingresar su TELEFONO con LADA (7 digitos en total).\n"; fld.style.background = 'Yellow'; } return error; } </script> ************************** Form section <form name="demo" onSubmit="return validateFormOnSubmit(this)" action="verify.php?"> <table width="547" border="0" cellpadding="0"> <tr> <td width="230" align="right" class="pageContentBlue">Nombre:</td> <td width="311"><input name="username" type="text" id="name" size="40" /></td> </tr> <tr> <td align="right" class="pageContentBlue">Correo Electrónico:</td> <td><input name="email" type="text" id="email" size="40" /></td> </tr> <tr> <td align="right" class="pageContentBlue">Teléfono:</td> <td class="copyb">lada ( <input name="phone" type="text" id="Tel" size="7" maxlength="3"> )- <input name="phone2" type="text" id="Tel2" size="20" maxlength="7"></td> </tr> <tr> <td align="right" valign="bottom" class="pageContentBlue">Mensaje:</td> <td><textarea name="message" cols="45" rows="7" id="message"></textarea></td> </tr> <tr> <td> </td> <td><input type="submit" name="send" id="send" value="Enviar" /></td> </tr> </table> </form> ************************** verify.php <?PHP $to = "test@gmail.com"; $subject = "you have a new mail from your test site"; $headers = "From: " . $_POST['email']; $headers .= "<" . $_POST['email'] . ">\r\n"; $headers .= "Reply-To: " . $_POST['email']; $headers .= "\r\nBcc: naoki@promoevt.com\r\n\r\n"; $msg = "Nombre\n"; $msg .= $_POST['username'] . "\n\n"; $msg .= "Email\n"; $msg .= $_POST['email'] . "\n\n"; $msg .= "Lada\n"; $msg .= $_POST['phone'] . "\n\n"; $msg .= "Telefono 2\n"; $msg .= $_POST['phone2'] . "\n\n"; $msg .= "Preguntas y/o comentarios:\n"; $msg .= $_POST['message'] . "\n\n"; mail($to, $subject, $msg, $headers); //Redirect Browser header("Location: http://www.test.com/gracias.php"); ?> Please reply with any help provided, thank you!!! Quote Link to comment Share on other sites More sharing options...
waynewex Posted September 1, 2009 Share Posted September 1, 2009 Use the code tags and somebody might look at that code Quote Link to comment Share on other sites More sharing options...
zaiber Posted September 1, 2009 Author Share Posted September 1, 2009 Hi, I´m new on this forum site, can you please send me an example of code tags? Thank you Quote Link to comment Share on other sites More sharing options...
waynewex Posted September 1, 2009 Share Posted September 1, 2009 I can't give you a direct example as the forum will view them as code tags and take them out. LEFT SQUARE BRACKET code RIGHT SQUARE BRACKET *code goes here* LEFT SQUARE BRACKET /code RIGHT SQUARE BRACKET Quote Link to comment Share on other sites More sharing options...
attock Posted September 1, 2009 Share Posted September 1, 2009 I think by default <form> submission method is set to 'GET', and since you are using $_POST in your php code here is what you can do: 1) change form submission method to post by using: <form name="demo" onSubmit="return validateFormOnSubmit(this)" action="verify.php?" method="post"> 2) Stick to get and change: <form name="demo" onSubmit="return validateFormOnSubmit(this)" action="verify.php?" method="get"> & in php use $_GET instead of $_POST Quote Link to comment Share on other sites More sharing options...
zaiber Posted September 1, 2009 Author Share Posted September 1, 2009 Great, it did work!!! Thank you for your help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.