Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add "human input" code to existing script

Status
Not open for further replies.

adonim

Technical User
Dec 6, 2009
1
US
Hi,
I'm not a programmer, just read and modify tiniest bits, and here the problem:
My greeting card script has one place where it checks the email addresses, I guess that is where I have to add the code for "human input" check, but don't know how...

my script's (Bignosebird.com cardcgi v2.0) snippet:



sub valid_address
{
$testmail = $fields{'recip_email'};
if ($testmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
$testmail !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
{
return 0;
}
else
{
return 1;
}
}


sub bad_email
{
print <<__STOP_OF_BADMAIL__;
Content-type: text/html

<FONT SIZE="+1">
<B>
SORRY! Your request could not be processed because of an improper
recipient's e-mail address. Please use your back button to return
to the card screen and try again!
</B>
</FONT>
__STOP_OF_BADMAIL__
}




and here the code I need to add:


use CGI;
$q = new CGI;


use Digest::MD5 qw(md5_hex);
my $skey = 'ChangeIt'; # secret key
my $code = $q->param('code'); # user put code
my $session = $q->param('hv_sess');
my $hash = $q->param('hv_hash');
my $expire = 60*2; # seconds expire session

if (time - $session > $expire ) {
$errors .="ERROR: The code has expired.<br>";
}
if ($hash ne md5_hex($code,$skey,$session) ) {
$errors .="ERROR: Code Entered is wrong.<br>";

}



anyone could help me?
Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top