Procesar formulario
Publicado por Àlex (1 intervención) el 05/06/2007 20:08:35
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Hola!
Estoy encargado de hacer un sitio web, y hemos realizado un Formulario HTML,
y no sabemos como hacer que nos llegue cuando le dan a enviar. No queremos
usar <ACTION="mailto: [email protected]">, porque queremos que nos
llegue de una forma "invisible" al usuario, y de esta manera avisa que se va
a enviar un correo electrónico, se enviarán sus datos, etc....
Hemos pensado en PHP, ASP....pero no sabemos cómo hacerlo.
Y hemos copiado un CGI de una web, cambiando las variables y el directorio
de nuestro Perl....pero al darle a enviar nos sale: "Internal Server Error".
SDi alguien sabe donde está el fallo, u otra forma más sencilla para
conseguir que funcione el formulario y nos llegue la información
introducida, o se guarde en un fichero en nuestro servidor...lo que sea, que
nos ayude. MUCHAS GRACIAS.
Àlex
** ERROR al enviar ***************************************
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
*** Código del formulario: ********************************
<form method="POST" action="http://www.sempreendavant.com/cgi-bin/form.cgi"
onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript"
name="FrontPage_Form1">
<input type="text" size="26" maxlength="256" name="asunto"></font></p>
<p><font face="Arial"><strong>Escriba sus comentarios en el espacio
siguiente:</strong></font></p>
<dl>
<dd><font face="Arial">
<textarea name="comentar" rows="5" cols="42"></textarea></font></dd>
</dl>
<p><font face="Arial"><strong>Dinos cómo ponernos en contacto
contigo:</strong></font></p>
<dl>
<dd>
<table>
<tr>
<td><font face="Arial">
<input type="text" size="35" maxlength="50"
name="nombre"></font></td>
</tr>
<tr>
<td><font face="Arial">Grupo</font></td>
<td><font face="Arial">
<input type="text" name="grupo" size="35" maxlength="50"></font></td>
</tr>
<tr>
<td><font face="Arial">Correo electrónico</font></td>
<td><font face="Arial">
<input type="text" size="35" maxlength="25" value="@"
name="email"></font></td>
</tr>
</table></dd>
</dl>
</blockquote>
<p align="center"><font face="Arial"><input type="submit" value="Enviar
comentarios">
<input type="reset" value="Borrar formulario"></font></p>
</form>
_----------------------------------------
*** Codigo del CGI "form.cgi" ********************
#!/usr/bin/perl
# Definición del programa para enviar correo, debe dejarse sin cambios.
$progmail = '/usr/sbin/sendmail';
# Usuario al que se enviarán los mensajes. Deberá poner su alias de correo
electrónico.
$destino = '[email protected]';
# Indica que se trata de un documento HTML
print "Content-type: text/html\n\n";
# Obtiene la entrada
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Divide las variables entre nombre y valor.
@pairs = split(/&/, $buffer);
# Optiene todas las variables y sus valores
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
# Ahora enviamos el mail al $destino
open (SALIDA, "|$progmail $destino") || die "No puedo abrir $progmail!\n";
print SALIDA "Reply-to: $FORM{'email'} ($FORM{'nombre'} $FORM{'grupo'})\n";
print SALIDA "Subject: Comentarios al formulario de www.sempreendavant.com
($FORM{'nombre'} $FORM{'grupo'})\n\n";
print SALIDA "$FORM{'nombre'} $FORM{'grupo'} del $FORM{'asunto'}envio \n";
print SALIDA "El siguiente comentario::\n\n";
print SALIDA
"------------------------------------------------------------\n";
print SALIDA "$FORM{'comentar'}";
print SALIDA
"\n------------------------------------------------------------\n";
close (SALIDA);
# Ahora enviamos la salida al fichero:
/usr/local/etc/httpd/htdocs/dept/dept_img/datos/respuestas.htm
open (SALIDA, ">> /usr/etc/httpd/htdocs/dept/dept_img/datos/respuestas.htm")
|| die "No puedo abrir el fichero!\n";
print SALIDA "<hr>\n"
print SALIDA "<b>$FORM{'nombre'} $FORM{'apellidos'}</b> del
<i>$FORM{'estamento'}</i> envio <br>\n";
print SALIDA "El siguiente comentario:<p>\n\n";
print SALIDA "<pre>\n"
print SALIDA
"------------------------------------------------------------\n";
print SALIDA "$FORM{'comentar'}";
print SALIDA
"\n------------------------------------------------------------\n";
print SALIDA "</pre>\n"
close (SALIDA);
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Hola!
Estoy encargado de hacer un sitio web, y hemos realizado un Formulario HTML,
y no sabemos como hacer que nos llegue cuando le dan a enviar. No queremos
usar <ACTION="mailto: [email protected]">, porque queremos que nos
llegue de una forma "invisible" al usuario, y de esta manera avisa que se va
a enviar un correo electrónico, se enviarán sus datos, etc....
Hemos pensado en PHP, ASP....pero no sabemos cómo hacerlo.
Y hemos copiado un CGI de una web, cambiando las variables y el directorio
de nuestro Perl....pero al darle a enviar nos sale: "Internal Server Error".
SDi alguien sabe donde está el fallo, u otra forma más sencilla para
conseguir que funcione el formulario y nos llegue la información
introducida, o se guarde en un fichero en nuestro servidor...lo que sea, que
nos ayude. MUCHAS GRACIAS.
Àlex
** ERROR al enviar ***************************************
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
*** Código del formulario: ********************************
<form method="POST" action="http://www.sempreendavant.com/cgi-bin/form.cgi"
onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript"
name="FrontPage_Form1">
<input type="text" size="26" maxlength="256" name="asunto"></font></p>
<p><font face="Arial"><strong>Escriba sus comentarios en el espacio
siguiente:</strong></font></p>
<dl>
<dd><font face="Arial">
<textarea name="comentar" rows="5" cols="42"></textarea></font></dd>
</dl>
<p><font face="Arial"><strong>Dinos cómo ponernos en contacto
contigo:</strong></font></p>
<dl>
<dd>
<table>
<tr>
<td><font face="Arial">
<input type="text" size="35" maxlength="50"
name="nombre"></font></td>
</tr>
<tr>
<td><font face="Arial">Grupo</font></td>
<td><font face="Arial">
<input type="text" name="grupo" size="35" maxlength="50"></font></td>
</tr>
<tr>
<td><font face="Arial">Correo electrónico</font></td>
<td><font face="Arial">
<input type="text" size="35" maxlength="25" value="@"
name="email"></font></td>
</tr>
</table></dd>
</dl>
</blockquote>
<p align="center"><font face="Arial"><input type="submit" value="Enviar
comentarios">
<input type="reset" value="Borrar formulario"></font></p>
</form>
_----------------------------------------
*** Codigo del CGI "form.cgi" ********************
#!/usr/bin/perl
# Definición del programa para enviar correo, debe dejarse sin cambios.
$progmail = '/usr/sbin/sendmail';
# Usuario al que se enviarán los mensajes. Deberá poner su alias de correo
electrónico.
$destino = '[email protected]';
# Indica que se trata de un documento HTML
print "Content-type: text/html\n\n";
# Obtiene la entrada
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Divide las variables entre nombre y valor.
@pairs = split(/&/, $buffer);
# Optiene todas las variables y sus valores
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
# Ahora enviamos el mail al $destino
open (SALIDA, "|$progmail $destino") || die "No puedo abrir $progmail!\n";
print SALIDA "Reply-to: $FORM{'email'} ($FORM{'nombre'} $FORM{'grupo'})\n";
print SALIDA "Subject: Comentarios al formulario de www.sempreendavant.com
($FORM{'nombre'} $FORM{'grupo'})\n\n";
print SALIDA "$FORM{'nombre'} $FORM{'grupo'} del $FORM{'asunto'}envio \n";
print SALIDA "El siguiente comentario::\n\n";
print SALIDA
"------------------------------------------------------------\n";
print SALIDA "$FORM{'comentar'}";
print SALIDA
"\n------------------------------------------------------------\n";
close (SALIDA);
# Ahora enviamos la salida al fichero:
/usr/local/etc/httpd/htdocs/dept/dept_img/datos/respuestas.htm
open (SALIDA, ">> /usr/etc/httpd/htdocs/dept/dept_img/datos/respuestas.htm")
|| die "No puedo abrir el fichero!\n";
print SALIDA "<hr>\n"
print SALIDA "<b>$FORM{'nombre'} $FORM{'apellidos'}</b> del
<i>$FORM{'estamento'}</i> envio <br>\n";
print SALIDA "El siguiente comentario:<p>\n\n";
print SALIDA "<pre>\n"
print SALIDA
"------------------------------------------------------------\n";
print SALIDA "$FORM{'comentar'}";
print SALIDA
"\n------------------------------------------------------------\n";
print SALIDA "</pre>\n"
close (SALIDA);
Valora esta pregunta


0