@zerokilled
Por lo que se puede apreciar, @estudiosol está usando una tradicional script escrita en Perl, llamada FormMail Cgi (
http://www.scriptarchive.com/readme/formmail.html), yo la usé incluso durante mucho tiempo antes de migrar a PHP y suele venir preinstalada en muchos servidores
La validación la realiza la misma script a través de la correcta configuración de los campos. Se vale a si mismo de determinados campos de tipo hidden para pasar información entre la script y el formulario, a saber
Código HTML:
Ver originalNecessary Form Fields
There is only one form field that you must have in your form, for FormMail to work correctly. This is the recipient field.
Field: recipient
Description: This form field allows you to specify to whom you wish for your form results to be mailed. Most likely you will want to configure this option as a hidden form field with a value equal to that of your e-mail address.
As of version 1.8, You can include multiple recipients by separating the values with commas.
es decir que el campo de nombre recipient esta diseñado para indicar el ó las direcciones de correo del destinatario...
Código HTML:
Ver originalField: email
Description: This form field will allow the user to specify their return e-mail address. If you want to be able to return e-mail to your user, I strongly suggest that you include this form field and allow them to fill it in. This will be put into the From: field of the message you receive. If you want to require an email address with valid syntax, add this field name to the required field.
Syntax:
<input type=text name="email">
el campo de nombre email valida la sintáxis de email de dicho campo,
Código HTML:
Ver originalField: required
Version: 1.3 & Up
Description: You can now require for certain fields in your form to be filled in before the user can successfully submit the form. Simply place all field names that you want to be mandatory into this field. If the required fields are not filled in, the user will be notified of what they need to fill in, and a link back to the form they just submitted will be provided.
To use a customized error page, see missing_fields_redirect
Syntax: If you want to require that they fill in the email and phone fields in your form, so that you can reach them once you have received the mail, use a syntax like:
<input type=hidden name="required" value="email,phone">
este es esencialmente el que parece estar faltándole a @estudiosol, ese campo oculto, de nombre "required", tiene por valor, el ó los nombres separados por comas, de los campos que sean obligatorios
en su ejemplo, por ejemplo
<input type=hidden name="required" value="email,subject,nombrevisitante">
solo para ampliar, la validación de campos requeridos se realiza con
Código perl:
Ver originalsub check_required {
# Localize the variables used in this subroutine. #
# The following insures that there were no newlines in any fields which #
# will be used in the header. #
if ($Config{'subject'} =~ /(\n|\r)/m || $Config{'email'} =~ /(\n|\r)/m ||
$Config{'realname'} =~ /(\n|\r)/m || $Config{'recipient'} =~ /(\n|\r)/m) {
&error('invalid_headers');
}
# Fix XSS + HTTP Header Injection for v1.93
foreach $lfield ('redirect', 'return_link_url') {
# Strip new lines
$Config{$lfield} =~ s/(\n|\r)//mg;
# Only allow certain handlers to avoid javascript:/data: tricks
if ($Config{$lfield} !~ /^\s*\// &&
$Config{$lfield} !~ /^\s*(http|https|ftp):\/\//) {
$Config{$lfield} = '';
}
}
if (!$Config{'recipient'}) {
if (!defined(%Form)) { &error('bad_referer') } else { &error('no_recipient') }
}
else {
# This block of code requires that the recipient address end with #
# a valid domain or e-mail address as defined in @recipients. #
foreach $send_to (split(/,/,$Config{'recipient'})) { foreach $recipient (@recipients) {
if ($send_to =~ /$recipient$/i) {
push(@send_to,$send_to); last; }
}
}
if ($#send_to < 0) { &error('no_recipient') }
$Config{'recipient'} = join(',',@send_to); }
# For each require field defined in the form: #
foreach $require (@Required) {
# If the required field is the email field, the syntax of the email #
# address if checked to make sure it passes a valid syntax. #
if ($require eq 'email' && !&check_email($Config{$require})) {
}
# Otherwise, if the required field is a configuration field and it #
# has no value or has been filled in with a space, send an error. #
elsif (defined($Config{$require})) { if ($Config{$require} eq '') { push(@error,$require); } }
# If it is a regular form field which has not been filled in or #
# filled in with a space, flag it as an error field. #
elsif (!defined($Form{$require}) || $Form{$require} eq '') { }
}
# If any error fields have been found, send error message to the user. #
if (@error) { &error('missing_fields', @error) }
}
La documentación de la script esta muy detallada (en inglés), pero de segiro si busca, va a encontrar más de un tutorial es español para la Matt's Script FormMail CGI
Saludos