Gossamer Forum
Home : General : Perl Programming :

Unknow problem. Idiot problem.

Quote Reply
Unknow problem. Idiot problem.
  I have a script, and it works well, but there is a problem when redirecting the user, this is the piece o the code with error

sub enviar {

open (MAIL, "|$mailprog -t") | | die "Canīt open Mail Prog $mailprog";
print MAIL "To: $meu_nome <$meu_email>\n";
print MAIL "From: $form{'nome'} <$form{'email'}>\n";
print MAIL "Subject: subject\n\n";
print MAIL "Message.\n";
close (MAIL);

open (MAIL, "|$mailprog -t") &#0124; &#0124; die "Canīt open Mail Prog $mailprog";
print MAIL "To: $form{'nome'} <$form{'email'}\n";
print MAIL "From: Name <mail\@mail.com>\n";
print MAIL "Subject: Pedido\n\n";
print MAIL "\n Thank you. ";
close (MAIL);

print "Location: http://www.geocities.com/~tmoretti\n\n";
}

The error is "malformed header name=xxx" where xxx is the input name of the person.. Can someone help?
Quote Reply
Re: Unknow problem. Idiot problem. In reply to
I think this:

Code:

print "Location: http://www.geocities.com/~tmoretti\n\n";

should look like this:

Code:

print "Location: http://www.geocities.com/\~tmoretti\n\n";

See, if it works.


Regards,

Pasha

------------------
webmaster@find.virtualave.net
http://find.virtualave.net
Quote Reply
Re: Unknow problem. Idiot problem. In reply to
Hi Pasha. It didnīt worked? Do you have any other idea?
Quote Reply
Re: Unknow problem. Idiot problem. In reply to
Try:

Quote:
print "Location: http://www.geocities.com/%7Etmoretti\n\n";

%7E represents the hexadecimal equivalent of the "~" character.

I hope this helps.
Quote Reply
Re: Unknow problem. Idiot problem. In reply to
The problem is, I changed the URL, now it's www.buscabr.com and I can't get it working.. Do you want I post the complete code here?
Quote Reply
Re: Unknow problem. Idiot problem. In reply to
Try:

Quote:
print "Content-type: text/html\n\n";
print "Location: http://www.buscabr.com/\n";

I added the first line because it may be necessary if it was not done before calling the subroutine.

I hope this helps.


[This message has been edited by Bobsie (edited April 21, 1999).]
Quote Reply
Re: Unknow problem. Idiot problem. In reply to
 
Quote:
"malformed header name=xxx"

This is a sendmail error, probably caused by this line:

Quote:
print MAIL "To: $form{'nome'} <$form{'email'}\n";

Note, no closing > for the email. You will also get this error if somebody enters in an invalid email address.

Hope this helps,

Alex
Quote Reply
Re: Unknow problem. Idiot problem. In reply to
Thank you. The problem was what Alex said. I forgot to close > the emails....

Bobsie:
It worked without the content-type. Why? Should I put it or not?
Quote Reply
Re: Unknow problem. Idiot problem. In reply to
Howdy,

I'd appreciate if someone would clarify this for me too please. I've seen print Location posted several times on this forum and quite a lot of the time with the Content-type header before it. I was under the impression that if you print a Location header after a Content-type header, the browser has already been told that it's text or HTML that's a-comin', so it just prints the Location header out as text.

Aren't they two totally different things? Or do they work differently on different systems or something? I don't use Content-type before a Location header on either Win95 or BSDI3 and it works grand...

Cheers,
adam
Quote Reply
Re: Unknow problem. Idiot problem. In reply to
       I didnīt understand this too. Sometimes, people says to use it, sometimes they say itīs not to use it. I donīt know if I should use it or not.
Quote Reply
Re: Unknow problem. Idiot problem. In reply to
If the header, Content-type: text/html\n\n is printed someplace in the script before the subroutine in question is called, then it is not needed in the subroutine provided another header (maybe specifying text/plain) did not change things.

This header tells the browser what to expect next. Since print "Location: http://www.buscabr.com/\n"; involves html, we must tell the browser to expect it before it is printed so that it is interpreted correctly. If we wanted just to display the source of something, say a script file, then the header would say:

Quote:
print "Content-type: text/plain\n\n";

You would then open the cgi script file, read and print each line to the screen.

Does that explain it?
Quote Reply
Re: Unknow problem. Idiot problem. In reply to
Bobsie,

I unnerstand how the content-type headers work,I was just curious about using it with a location header.

I've just tested this locally and on my webspace and what I said is exactly what happens. If I send the content-type header before the location one, it just prints it as text.

I'm not saying you're wrong, maybe it's something to do with the OS or the Perl version, but that's the way it works for me. Can anybody clarify this? I'm asking because I've even seeing Alex posting it with the content-type, so there's obviously gonna be some confusion...

Here's the tests on my server:

dotcgi.com/demos/location/

Cheers,
adam
Quote Reply
Re: Unknow problem. Idiot problem. In reply to
Ok, thatīs explained. But why it works without printing the content-type anywhere in the script? I just put the "Location: URL\n\n" and it works..