Gossamer Forum
Home : General : Perl Programming :

form script problems

Quote Reply
form script problems
 Making this slightly advanced form script.
Sends the users input to the webmaster and can store it in a file if the host wants it to.
I also added a bad word checker, based on one I got at this forum not long ago.

But I have some problems. For the first. I can't seem to get the email to be send while I'm doing this: I have a variable named $recipient.
It contains my email address. I have placed the variable to be printed after the To: in the sendmail sub.
But I get this message over the thank you page(?!).
Quote:
No recipient addresses found in header

Really strange. It displays the thank you page, but it doesn't send the email!
This has never happened to me before. If I just type my address in the To: print sentence it works fine.
Really weird!

The next thing is the checking of the email address the user post.
Code:
if ($FORM{'emailfrom'} !~ /\S+@\S+\.\S+/) {
blackout("The email you entered was invalid. Please go back and try again.\n");}
}
It works fine. (Thank you Paul for posting it here earlier.) But, yes BUT, there is one thing. A friend of mine asked me if this code would stop someone from just typing something like xxx@xxx.com.
Ehh...I tried. Nope. Maybe that ain't possible?
Just a thought, Paul.

The third is the checking of message. That one doesn't work at all. It sends the message even if I don't have filled in anything!
Code:
if(!$FORM{'message'}) {blackout("You must write something! Or else the meaning of filling out this form is waisted. Please go back.\n");}

That don't work. I'm not sure if I posted enough for you to understand. I have tested it, even with and without use strict; With strict tons of error comes up and it I get this typical sever error when trying it.

Any tips? I don't won't to post the full script here yet. I might publish it later for free, but I want to keep the code mostly for myself for a while.

Thanks.

- perlman
Quote Reply
Re: [perlman] form script problems In reply to
Try something like;

[0-9a-z]([-_.+]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,}$

....or you may want to add some {,} bits in there, like {3,} which would make them have to enter at least 3 charachters before it will be accepted.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] form script problems In reply to
I've mentioned to you before that, that regex is bad for matching emails.
Quote Reply
Re: [Paul] form script problems In reply to
Whats so bad about it? Has worked fine for me for about 2 months.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] form script problems In reply to
http://search.cpan.org/...-Valid-0.14/Valid.pm

- wil
Quote Reply
Re: [Wil] form script problems In reply to
That Regex was from a PHP script (notice how i didn't include the eregi() code Tongue)

Either way, that module looks quite cool :) i may give it a go with something like this in one of my scripts (have a look at the source, and maybe use LWP::Simple to grab the URl to see if it is live).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] form script problems In reply to
Yeah, if you take a look at the source, it uses that massive regex that's probabyl been pasted here a hundred times.

http://search.cpan.org/...-Valid-0.14/Valid.pm

- wil
Quote Reply
Re: [Wil] form script problems In reply to
Cool Cool

Is there alsow a PHP version of this feature by any chance...
Quote Reply
Re: [cK] form script problems In reply to
Not sure. Is there anything available on PEAR?

I know nothing about PHP, does it use a similar regex pattern to Perl? If it does, then maybe you can inorporate that regex into your PHP script somehow?

But then again, that is the advantage of Perl over PHP (IMO - one of) is that there is a huge code library waiting for you at the CPAN, where PHP, being a newer language hasn't quite got the same library as Perl, well, not even close really.

- wil
Quote Reply
Re: [Wil] form script problems In reply to
I know know Wink

But started coding PHP 3 weeks ago (after years of perl) and must say: it's very easy... "Write what you think" and it works! That's why all my new scripts are in php/mysql Wink