1752730 Members
5485 Online
108789 Solutions
New Discussion юеВ

Re: CGI, how to exit ?

 
David_246
Trusted Contributor

CGI, how to exit ?

Hi,

I would like to check my incomming values to be a real e-mail adres. Unfortunetly when they do not pass I'dd like to exit. This comes with an error. Premature end of Header.
When I leave the exit, the scipt continues and prints the start html-page again.

if ((grep !/\./, $mailadres) || (grep !/@/, $mailadres)) {
print "
Error: E-mail adres has to contain an @ and a .
";
exit;

How do I exit without the premature end of script message?


Regs David
@yourservice
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: CGI, how to exit ?

In a cgi script you can do email addresses in single quotes.

email='someone@your.net';

That avoides the problem of the special character @ which requires a / before it to not casue the premature header error.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ramkumar Devanathan
Honored Contributor

Re: CGI, how to exit ?

David,

I think you are missing a curly bracket, before the exit command.

Otherwise, there is no problem with the code or the exit instance.

>>
if ((grep !/\./, $mailadres) || (grep !/@/, $mailadres)) {
print "
Error: E-mail adres has to contain an @ and a .
"; }
exit;
<<

Should work!

- ramd.
HPE Software Rocks!
Elmar P. Kolkman
Honored Contributor

Re: CGI, how to exit ?

You could try to add two newlines to the start of your print... The problem is you need some newlines between your HTML header and the HTML code. If those are missing, you get an error message like the one you got.

Every problem has at least one solution. Only some solutions are harder to find.
Elmar P. Kolkman
Honored Contributor

Re: CGI, how to exit ?

If the curly bracket is your problem, I would place it behind the exit instead of before ;-)
Every problem has at least one solution. Only some solutions are harder to find.
Ramkumar Devanathan
Honored Contributor

Re: CGI, how to exit ?

Oops!

Thanks elmar for pointing that out.

- ramd.
HPE Software Rocks!