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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Registration Form Issue 1

Status
Not open for further replies.

chrismassey

Programmer
Aug 24, 2007
264
GB
Hello,

I have almost finished a user registration form. Currently I have not completed the validation (regex) of form fields, though it is pretty much ready.

Whilst testing I suddenly came across an Error 500, and I have no idea why. It was working before so I can only assume i've made a mistake somewhere.

Syntax checker simply says there is a syntax error at line 303, aborted at line 350. Therefore I assumed it is to do with this section...

Code:
## Create a subscriptions file in user folder and copy contents of default subscriptions file
open (LOG, "<$secure_path$d_subscriptions_file_loc") || die "Cannot open: $secure_path$d_subscriptions_file_loc";
flock (LOG, 2) || die "Cannot flock: $secure_path$d_subscriptions_file_loc";
my @log1 = <LOG>;
close (LOG) || die "Cannot close: $secure_path$d_subscriptions_file_loc";

Any ideas why it no longer works, considering it was working perfectly before. The only change I can remember making before it stopped working was a simple change within a qq() tag just before the failing section.

Although I do not expect anyone to read through it, I will post my entire code in case...

Code:
[ol]
[li][gray]#! /usr/bin/perl[/gray][/li]
[li][url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]strict[/green][red];[/red][/li]
[li][black][b]use[/b][/black] [green]CGI[/green] [red]'[/red][purple]:standard[/purple][red]'[/red][red];[/red][/li]
[li][black][b]use[/b][/black] [green]diagnostics[/green][red];[/red][/li]
[li][black][b]use[/b][/black] [green]warnings[/green][red];[/red][/li]
[li][url=http://perldoc.perl.org/functions/print.html][black][b]print[/b][/black][/url] [red]"[/red][purple]Content-type: text/html[purple][b]\n[/b][/purple][purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red][/li]
[li][/li]
[li][gray][i]##### MODULES USED >>>>> | strict | CGI ':standard' | diagnostics | warnings | Mime::Lite | HTML::Template |[/i][/gray][/li]
[li][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [red]([/red][blue]$date_time[/blue][red])[/red][red];[/red][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$sec[/blue], [blue]$min[/blue], [blue]$hour[/blue], [blue]$mday[/blue], [blue]$mon[/blue], [blue]$year[/blue][red])[/red]=[url=http://perldoc.perl.org/functions/gmtime.html][black][b]gmtime[/b][/black][/url][red];[/red][/li]
[li][gray][i]##### DATE/TIME[/i][/gray][/li]
[li][blue]$date_time[/blue] = [url=http://perldoc.perl.org/functions/sprintf.html][black][b]sprintf[/b][/black][/url] [red]([/red][red]'[/red][purple]%02d/%02d/%4d - %02d:%02d:%02d[/purple][red]'[/red], [blue]$mday[/blue], [blue]$mon[/blue]+[fuchsia]1[/fuchsia], [blue]$year[/blue]+[fuchsia]1900[/fuchsia], [blue]$hour[/blue], [blue]$min[/blue], [blue]$sec[/blue][red])[/red][red];[/red][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$validate_counter[/blue], [blue]$secure_path[/blue], [blue]$users_folder_path[/blue], [blue]$event_log_path[/blue], [blue]$profile_file_name[/blue], [blue]$subscriptions_file_name[/blue], [blue]$d_subscriptions_file_loc[/blue][red])[/red][red];[/red][/li]
[li][gray][i]##### INITIAL VALUES - ## 1, validation counter initial value - ## 2, path to secure directory - ## 3, path to users directory - ## 4, path to events log file - ## 5, profile file name - ## 6, subscriptions file name - ## 7, default subscriptions file path[/i][/gray][/li]
[li][gray][i]## 1[/i][/gray][/li]
[li][blue]$validate_counter[/blue] = 		[fuchsia]0[/fuchsia][red];[/red][/li]
[li][gray][i]## 2[/i][/gray][/li]
[li][blue]$secure_path[/blue] = 			[red]"[/red][purple]/PATH/[/purple][red]"[/red][red];[/red][/li]
[li][gray][i]## 3[/i][/gray][/li]
[li][blue]$users_folder_path[/blue] = 		[red]"[/red][purple]Users/[/purple][red]"[/red][red];[/red][/li]
[li][gray][i]## 4[/i][/gray][/li]
[li][blue]$event_log_path[/blue] =               [red]"[/red][purple]Admin/Logs/Event_Log/event_log.htm[/purple][red]"[/red][red];[/red][/li]
[li][gray][i]## 5[/i][/gray][/li]
[li][blue]$profile_file_name[/blue] =      	[red]"[/red][purple]/profile.txt[/purple][red]"[/red][red];[/red][/li]
[li][gray][i]## 6[/i][/gray][/li]
[li][blue]$subscriptions_file_name[/blue] =      [red]"[/red][purple]/subscriptions.txt[/purple][red]"[/red][red];[/red][/li]
[li][gray][i]## 7[/i][/gray][/li]
[li][blue]$d_subscriptions_file_loc[/blue] =     [red]"[/red][purple]Default_Subscriptions_File/default_subscriptions.txt[/purple][red]"[/red][red];[/red][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][gray][i]##### FAILED VALIDATION MESSAGES[/i][/gray][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$execution_check_m[/blue][red])[/red][red];[/red][/li]
[li][gray][i]## EXECUTION CHECK[/i][/gray][/li]
[li][blue]$execution_check_m[/blue] = 		[red]'[/red][purple]Illegal Access[/purple][red]'[/red][red];[/red][/li]
[li][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$html_begin[/blue], [blue]$html_end[/blue][red])[/red][red];[/red][/li]
[li][gray][i]## HTML Tags[/i][/gray][/li]
[li][blue]$html_begin[/blue] = 			[red]qq([/red][purple]<font size="2" color="#FF0000" face="Arial"><LI>[/purple][red])[/red][red];[/red][/li]
[li][blue]$html_end[/blue] = 			[red]qq([/red][purple]<br></font>[/purple][red])[/red][red];[/red][/li]
[li][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$choose_username_m[/blue], [blue]$choose_usernameb_m[/blue], [blue]$choose_password_m[/blue], [blue]$confirm_password_m[/blue], [blue]$title_m[/blue], [blue]$other_title_m[/blue], [blue]$first_name_m[/blue], [blue]$last_name_m[/blue], [blue]$email_m[/blue], [blue]$confirm_email_m[/blue], [blue]$address_1_m[/blue], [blue]$address_2_m[/blue], [blue]$town_city_m[/blue], [blue]$county_m[/blue], [blue]$postcode_m[/blue], [blue]$country_m[/blue], [blue]$telephone_m[/blue], [blue]$fax_m[/blue], [blue]$accept_terms_m[/blue][red])[/red][red];[/red][/li]
[li][gray][i]## MESSAGES[/i][/gray][/li]
[li][blue]$choose_username_m[/blue] = 		[red]'[/red][purple]Choose A Username - Username must be 4-20 characters long (a-z, 0-9, _ ONLY).[/purple][red]'[/red][red];[/red][/li]
[li][blue]$choose_usernameb_m[/blue] = 		[red]'[/red][purple]Choose A Username - This Username already exists. Please choose another.[/purple][red]'[/red][red];[/red][/li]
[li][blue]$choose_password_m[/blue] = 		[red]'[/red][purple]Choose A Password - Password must be atleast 8 chracters long.[/purple][red]'[/red][red];[/red][/li]
[li][blue]$confirm_password_m[/blue] = 		[red]'[/red][purple]Confirm Your password - Does not match your Password.[/purple][red]'[/red][red];[/red][/li]
[li][blue]$title_m[/blue] = 			[red]'[/red][purple]Title - Choose one.[/purple][red]'[/red][red];[/red][/li]
[li][blue]$other_title_m[/blue] = 		[red]'[/red][purple]Other Title - If Title=Other, please specify (a-z, A-Z ONLY).[/purple][red]'[/red][red];[/red][/li]
[li][blue]$first_name_m[/blue] = 		[red]'[/red][purple]First Name - First Name must be no more than 40 characters long (a-z, A-Z ONLY).[/purple][red]'[/red][red];[/red][/li]
[li][blue]$last_name_m[/blue] = 			[red]'[/red][purple]Last Name - Last Name must be no more than 40 characters long (a-z, A-Z ONLY).[/purple][red]'[/red][red];[/red][/li]
[li][blue]$email_m[/blue] = 			[red]'[/red][purple]Email Address - I.E. email@domain.com.[/purple][red]'[/red][red];[/red][/li]
[li][blue]$confirm_email_m[/blue] =		[red]'[/red][purple]Confirm Email Address - Does not match your Email.[/purple][red]'[/red][red];[/red][/li]
[li][blue]$address_1_m[/blue] = 			[red]'[/red][purple]Address Line 1 - (a-z, A-Z, 0-9 ONLY).[/purple][red]'[/red][red];[/red][/li]
[li][blue]$address_2_m[/blue] = 			[red]'[/red][purple]Address Line 2 - (a-z, A-Z, 0-9 ONLY).[/purple][red]'[/red][red];[/red][/li]
[li][blue]$town_city_m[/blue] = 			[red]'[/red][purple]Town/City - (a-z, A-Z, ONLY).[/purple][red]'[/red][red];[/red][/li]
[li][blue]$county_m[/blue] = 			[red]'[/red][purple]County - (a-z, A-Z, ONLY).[/purple][red]'[/red][red];[/red][/li]
[li][blue]$postcode_m[/blue] = 			[red]'[/red][purple]Postcode - (a-z, A-Z, 0-9 ONLY).[/purple][red]'[/red][red];[/red][/li]
[li][blue]$country_m[/blue] = 			[red]'[/red][purple]Country - Choose one.[/purple][red]'[/red][red];[/red][/li]
[li][blue]$telephone_m[/blue] = 			[red]'[/red][purple]Telephone - Telephone must be exactly 11 numbers long (0-9, +s ONLY).[/purple][red]'[/red][red];[/red][/li]
[li][blue]$fax_m[/blue] = 			[red]'[/red][purple]Fax - Fax must be exactly 11 numbers long (0-9, +s ONLY).[/purple][red]'[/red][red];[/red][/li]
[li][blue]$accept_terms_m[/blue] = 		[red]'[/red][purple]Accept Terms And Conditions - Checkbox has now been ticked. Untick if you do not accept the Terms And Conditions.[/purple][red]'[/red][red];[/red][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$choose_username[/blue], [blue]$choose_password[/blue], [blue]$confirm_password[/blue], [blue]$title[/blue], [blue]$other_title[/blue], [blue]$first_name[/blue], [blue]$last_name[/blue], [blue]$email[/blue], [blue]$confirm_email[/blue], [blue]$address_1[/blue], [blue]$address_2[/blue], [blue]$town_city[/blue], [blue]$county[/blue], [blue]$postcode[/blue], [blue]$country[/blue], [blue]$telephone[/blue], [blue]$fax[/blue], [blue]$accept_terms[/blue], [blue]$execution_check[/blue][red])[/red][red];[/red][/li]
[li][gray][i]##### CONNECT TO REGISTRATION FORM[/i][/gray][/li]
[li][blue]$choose_username[/blue] = 		[maroon]param[/maroon][red]([/red][red]'[/red][purple]choose_username[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$choose_password[/blue] = 		[maroon]param[/maroon][red]([/red][red]'[/red][purple]choose_password[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$confirm_password[/blue] =		[maroon]param[/maroon][red]([/red][red]'[/red][purple]confirm_password[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$title[/blue] = 			[maroon]param[/maroon][red]([/red][red]'[/red][purple]title[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$other_title[/blue] = 			[maroon]param[/maroon][red]([/red][red]'[/red][purple]other_title[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$first_name[/blue] = 			[maroon]param[/maroon][red]([/red][red]'[/red][purple]first_name[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$last_name[/blue] = 			[maroon]param[/maroon][red]([/red][red]'[/red][purple]last_name[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$email[/blue] = 			[maroon]param[/maroon][red]([/red][red]'[/red][purple]email[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$confirm_email[/blue] = 		[maroon]param[/maroon][red]([/red][red]'[/red][purple]confirm_email[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$address_1[/blue] = 			[maroon]param[/maroon][red]([/red][red]'[/red][purple]address_1[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$address_2[/blue] = 			[maroon]param[/maroon][red]([/red][red]'[/red][purple]address_2[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$town_city[/blue] = 			[maroon]param[/maroon][red]([/red][red]'[/red][purple]town_city[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$county[/blue] = 			[maroon]param[/maroon][red]([/red][red]'[/red][purple]county[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$postcode[/blue] = 			[maroon]param[/maroon][red]([/red][red]'[/red][purple]postcode[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$country[/blue] = 			[maroon]param[/maroon][red]([/red][red]'[/red][purple]country[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$telephone[/blue] = 			[maroon]param[/maroon][red]([/red][red]'[/red][purple]telephone[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$fax[/blue] = 				[maroon]param[/maroon][red]([/red][red]'[/red][purple]fax[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$accept_terms[/blue] = 		[maroon]param[/maroon][red]([/red][red]'[/red][purple]accept_terms[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][blue]$execution_check[/blue] = 		[maroon]param[/maroon][red]([/red][red]'[/red][purple]execution_check[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][gray][i]## CHECK SCRIPT WAS EXECUTED FROM REGISTRATION FORM[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$execution_check[/blue] == [fuchsia]1[/fuchsia][red])[/red] [red]{[/red][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][gray][i]## VARIABLE CONVERSIONS[/i][/gray][/li]
[li][gray][i]## Change choose_username to lowercase characters[/i][/gray][/li]
[li][blue]$choose_username[/blue] = [url=http://perldoc.perl.org/functions/lc.html][black][b]lc[/b][/black][/url][red]([/red][blue]$choose_username[/blue][red])[/red][red];[/red][/li]
[li][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$validate_1_warn[/blue], [blue]$validate_1b_warn[/blue], [blue]$validate_2_warn[/blue], [blue]$validate_3_warn[/blue], [blue]$validate_4_warn[/blue], [blue]$validate_5_warn[/blue], [blue]$validate_6_warn[/blue], [blue]$validate_7_warn[/blue], [blue]$validate_8_warn[/blue], [blue]$validate_9_warn[/blue], [blue]$validate_10_warn[/blue], [blue]$validate_11_warn[/blue], [blue]$validate_12_warn[/blue], [blue]$validate_13_warn[/blue], [blue]$validate_14_warn[/blue], [blue]$validate_15_warn[/blue], [blue]$validate_16_warn[/blue], [blue]$validate_17_warn[/blue], [blue]$validate_18_warn[/blue][red])[/red][red];[/red][/li]
[li][gray][i]##### VALIDATE REGISTRATION FORM[/i][/gray][/li]
[li][gray][i]####################################### 1[/i][/gray][/li]
[li][gray][i]##Regex## choose_username[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$choose_username[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red][/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_1_warn[/blue] = [red]qq([/red][purple]$html_begin$choose_username_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 2 [/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][url=http://perldoc.perl.org/functions/-X.html][black][b]-d[/b][/black][/url] [red]"[/red][purple][blue]$secure_path[/blue][blue]$users_folder_path[/blue][blue]$choose_username[/blue][/purple][red]"[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_1b_warn[/blue] = [red]qq([/red][purple]$html_begin$choose_usernameb_m$html_end[/purple][red])[/red] [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 3[/i][/gray][/li]
[li][gray][i]##Regex## choose_password[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$choose_password[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_2_warn[/blue] = [red]qq([/red][purple]$html_begin$choose_password_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 4[/i][/gray][/li]
[li][gray][i]## confirm_password[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$confirm_password[/blue] eq [red]"[/red][purple][blue]$choose_password[/blue][/purple][red]"[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_3_warn[/blue] = [red]qq([/red][purple]$html_begin$confirm_password_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 5[/i][/gray][/li]
[li][gray][i]## title[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$title[/blue] != [red]"[/red][purple]1[/purple][red]"[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_4_warn[/blue] = [red]qq([/red][purple]$html_begin$title_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 6[/i][/gray][/li]
[li][gray][i]##Regex## other_title[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$title[/blue] eq [red]"[/red][purple]Other[/purple][red]"[/red][red])[/red] [red]{[/red] [/li]
[li]	[olive][b]if[/b][/olive] [red]([/red][blue]$other_title[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red] [/li]
[li]		[blue]$validate_counter[/blue]++ [red]}[/red][/li]
[li]	[olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]		[blue]$validate_5_warn[/blue] = [red]qq([/red][purple]$html_begin$other_title$html_end[/purple][red])[/red][red];[/red] [/li]
[li]	[red]}[/red] [/li]
[li][red]}[/red][/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_17_warn[/blue] = [red]"[/red][purple][/purple][red]"[/red][red];[/red][/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$title[/blue] ne [red]"[/red][purple]Other[/purple][red]"[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$other_title[/blue] = [red]"[/red][purple][/purple][red]"[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 7[/i][/gray][/li]
[li][gray][i]##Regex## first_name[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$first_name[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red][/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_6_warn[/blue] = [red]qq([/red][purple]$html_begin$first_name_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 8[/i][/gray][/li]
[li][gray][i]##Regex## last_name[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$last_name[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++[red];[/red] [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_7_warn[/blue] = [red]qq([/red][purple]$html_begin$last_name_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 9[/i][/gray][/li]
[li][gray][i]##Regex## email[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$email[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_8_warn[/blue] = [red]qq([/red][purple]$html_begin$email_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 10[/i][/gray][/li]
[li][gray][i]## confirm_email[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$confirm_email[/blue] eq [red]"[/red][purple][blue]$email[/blue][/purple][red]"[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_9_warn[/blue] = [red]qq([/red][purple]$html_begin$confirm_email_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 11[/i][/gray][/li]
[li][gray][i]##Regex## address_1[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$address_1[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red][/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_10_warn[/blue] = [red]qq([/red][purple]$html_begin$address_1_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 12[/i][/gray][/li]
[li][gray][i]##Regex## address_2[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$address_2[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_11_warn[/blue] = [red]qq([/red][purple]$html_begin$address_2_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$address_2[/blue] eq [red]"[/red][purple][/purple][red]"[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++[red];[/red] [blue]$validate_11_warn[/blue] = [red]"[/red][purple][/purple][red]"[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 13[/i][/gray][/li]
[li][gray][i]##Regex## town_city[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$town_city[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_12_warn[/blue] = [red]qq([/red][purple]$html_begin$town_city_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 14[/i][/gray][/li]
[li][gray][i]##Regex## county[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$county[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_13_warn[/blue] = [red]qq([/red][purple]$html_begin$county_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$county[/blue] eq [red]"[/red][purple][/purple][red]"[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++[red];[/red] [blue]$validate_13_warn[/blue] = [red]"[/red][purple][/purple][red]"[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 15[/i][/gray][/li]
[li][gray][i]##Regex## postcode[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$postcode[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_14_warn[/blue] = [red]qq([/red][purple]$html_begin$postcode_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 16[/i][/gray][/li]
[li][gray][i]## country[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$country[/blue] != [red]"[/red][purple]1[/purple][red]"[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_15_warn[/blue] = [red]qq([/red][purple]$html_begin$country_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 17[/i][/gray][/li]
[li][gray][i]##Regex## telephone[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$telephone[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_16_warn[/blue] = [red]qq([/red][purple]$html_begin$telephone_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 18[/i][/gray][/li]
[li][gray][i]##Regex## fax[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$fax[/blue] =~ [red]/[/red][purple][/purple][red]/[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++ [/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red] [/li]
[li]	[blue]$validate_17_warn[/blue] = [red]qq([/red][purple]$html_begin$fax_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$fax[/blue] eq [red]"[/red][purple][/purple][red]"[/red][red])[/red] [red]{[/red] [/li]
[li]	[blue]$validate_counter[/blue]++[red];[/red] [blue]$validate_17_warn[/blue] = [red]"[/red][purple][/purple][red]"[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]####################################### 19[/i][/gray][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$accept_terms_length[/blue][red])[/red][red];[/red][/li]
[li][gray][i]## accept_terms[/i][/gray][/li]
[li][blue]$accept_terms_length[/blue] = [url=http://perldoc.perl.org/functions/length.html][black][b]length[/b][/black][/url] [red]([/red][blue]$accept_terms[/blue][red])[/red][red];[/red][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$accept_terms_length[/blue] == [red]"[/red][purple]1[/purple][red]"[/red][red])[/red] [red]{[/red][/li]
[li]	[blue]$validate_counter[/blue]++[/li]
[li][red]}[/red] [/li]
[li][olive][b]else[/b][/olive] [red]{[/red][/li]
[li]	[blue]$validate_18_warn[/blue] = [red]qq([/red][purple]$html_begin$accept_terms_m$html_end[/purple][red])[/red][red];[/red] [/li]
[li][red]}[/red][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][gray][i]#### VALIDATION PASS[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$validate_counter[/blue] == [fuchsia]19[/fuchsia][red])[/red] [red]{[/red][/li]
[li][/li]
[li][gray][i]####################[/i][/gray][/li]
[li][gray][i]##### IF A NON-COMPULSORY FIELD IS BLANK, FILL IT WITH "None"[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$other_title[/blue] eq [red]"[/red][purple][/purple][red]"[/red][red])[/red] [red]{[/red] [blue]$other_title[/blue] = [red]"[/red][purple]None[/purple][red]"[/red][red];[/red] [red]}[/red][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$address_2[/blue] eq [red]"[/red][purple][/purple][red]"[/red][red])[/red] [red]{[/red] [blue]$address_2[/blue] = [red]"[/red][purple]None[/purple][red]"[/red][red];[/red] [red]}[/red][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$county[/blue] eq [red]"[/red][purple][/purple][red]"[/red][red])[/red] [red]{[/red] [blue]$county[/blue] = [red]"[/red][purple]None[/purple][red]"[/red][red];[/red] [red]}[/red][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$fax[/blue] eq [red]"[/red][purple][/purple][red]"[/red][red])[/red] [red]{[/red] [blue]$fax[/blue] = [red]"[/red][purple]None[/purple][red]"[/red][red];[/red] [red]}[/red][/li]
[li][/li]
[li][gray][i]####################[/i][/gray][/li]
[li][gray][i]## Create user folder[/i][/gray][/li]
[li][url=http://perldoc.perl.org/functions/mkdir.html][black][b]mkdir[/b][/black][/url] [red]([/red][red]"[/red][purple][blue]$secure_path[/blue][blue]$users_folder_path[/blue][blue]$choose_username[/blue][/purple][red]"[/red], [fuchsia]0777[/fuchsia][red])[/red] || [url=http://perldoc.perl.org/functions/die.html][black][b]die[/b][/black][/url] [red]"[/red][purple]Cannot Open: [blue]$secure_path[/blue][blue]$users_folder_path[/blue][blue]$choose_username[/blue][/purple][red]"[/red][red];[/red][/li]
[li][/li]
[li][gray][i]## Create a new profile in user folder[/i][/gray][/li]
[li][url=http://perldoc.perl.org/functions/open.html][black][b]open[/b][/black][/url] [red]([/red]LOG, [red]"[/red][purple]>[blue]$secure_path[/blue][blue]$users_folder_path[/blue][blue]$choose_username[/blue][blue]$profile_file_name[/blue][/purple][red]"[/red][red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot open: [blue]$secure_path[/blue][blue]$users_folder_path[/blue][blue]$choose_username[/blue][blue]$profile_file_name[/blue][/purple][red]"[/red][red];[/red][/li]
[li][url=http://perldoc.perl.org/functions/flock.html][black][b]flock[/b][/black][/url] [red]([/red]LOG, [fuchsia]2[/fuchsia][red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot flock: [blue]$secure_path[/blue][blue]$users_folder_path[/blue][blue]$choose_username[/blue][blue]$profile_file_name[/blue][/purple][red]"[/red][red];[/red][/li]
[li][black][b]print[/b][/black] LOG [red]"[/red][purple][blue]$choose_username[/blue]|[blue]$choose_password[/blue]|[blue]$title[/blue]|[blue]$other_title[/blue]|[blue]$first_name[/blue]|[blue]$last_name[/blue]|[blue]$email[/blue]|[blue]$address_1[/blue]|[blue]$address_2[/blue]|[blue]$town_city[/blue]|[blue]$county[/blue]|[blue]$postcode[/blue]|[blue]$country[/blue]|[blue]$telephone[/blue]|[blue]$fax[/blue]|[blue]$accept_terms[/blue]|[blue]$execution_check[/blue][/purple][red]"[/red][red];[/red][/li]
[li][url=http://perldoc.perl.org/functions/close.html][black][b]close[/b][/black][/url] [red]([/red]LOG[red])[/red][/li]
[li][/li]
[li][gray][i]## Create a subscriptions file in user folder and copy contents of default subscriptions file[/i][/gray][/li]
[li][black][b]open[/b][/black] [red]([/red]LOG, [red]"[/red][purple]<[blue]$secure_path[/blue][blue]$d_subscriptions_file_loc[/blue][/purple][red]"[/red][red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot open: [blue]$secure_path[/blue][blue]$d_subscriptions_file_loc[/blue][/purple][red]"[/red][red];[/red][/li]
[li][black][b]flock[/b][/black] [red]([/red]LOG, [fuchsia]2[/fuchsia][red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot flock: [blue]$secure_path[/blue][blue]$d_subscriptions_file_loc[/blue][/purple][red]"[/red][red];[/red][/li]
[li][black][b]my[/b][/black] [blue]@log1[/blue] = <LOG>[red];[/red][/li]
[li][black][b]close[/b][/black] [red]([/red]LOG[red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot close: [blue]$secure_path[/blue][blue]$d_subscriptions_file_loc[/blue][/purple][red]"[/red][red];[/red][/li]
[li][/li]
[li][black][b]open[/b][/black] [red]([/red]LOG, [red]"[/red][purple]>[blue]$secure_path[/blue][blue]$users_folder_path[/blue][blue]$choose_username[/blue][blue]$subscriptions_file_name[/blue][/purple][red]"[/red][red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot open: [blue]$secure_path[/blue][blue]$users_folder_path[/blue][blue]$choose_username[/blue][blue]$subscriptions_file_name[/blue][/purple][red]"[/red][red];[/red][/li]
[li][black][b]flock[/b][/black] [red]([/red]LOG, [fuchsia]2[/fuchsia][red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot flock: [blue]$secure_path[/blue][blue]$users_folder_path[/blue][blue]$choose_username[/blue][blue]$subscriptions_file_name[/blue][/purple][red]"[/red][red];[/red][/li]
[li][black][b]print[/b][/black] LOG [red]"[/red][purple][blue]@log1[/blue][/purple][red]"[/red][red];[/red][/li]
[li][black][b]close[/b][/black] [red]([/red]LOG[red])[/red][red];[/red][/li]
[li][gray][i]####################[/i][/gray][/li]
[li][gray][i]## Log new event[/i][/gray][/li]
[li][black][b]open[/b][/black] [red]([/red]LOG, [red]"[/red][purple]<[blue]$secure_path[/blue][blue]$event_log_path[/blue][/purple][red]"[/red][red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot open: [blue]$secure_path[/blue][blue]$event_log_path[/blue][/purple][red]"[/red][red];[/red][/li]
[li][black][b]flock[/b][/black] [red]([/red]LOG, [fuchsia]2[/fuchsia][red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot flock: [blue]$secure_path[/blue][blue]$event_log_path[/blue][/purple][red]"[/red][red];[/red][/li]
[li][black][b]my[/b][/black] [blue]@log2[/blue] = <LOG>[red];[/red][/li]
[li][black][b]close[/b][/black] [red]([/red]LOG[red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot close: [blue]$secure_path[/blue][blue]$event_log_path[/blue][/purple][red]"[/red][red];[/red][/li]
[li][/li]
[li][black][b]open[/b][/black] [red]([/red]LOG, [red]"[/red][purple]>[blue]$secure_path[/blue][blue]$event_log_path[/blue][/purple][red]"[/red][red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot open: [blue]$secure_path[/blue][blue]$event_log_path[/blue][/purple][red]"[/red][red];[/red][/li]
[li][black][b]flock[/b][/black] [red]([/red]LOG, [fuchsia]2[/fuchsia][red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot flock: [blue]$secure_path[/blue][blue]$event_log_path[/blue][/purple][red]"[/red][red];[/red][/li]
[li][black][b]print[/b][/black] LOG [red]qq([/red][purple][/purple][/li]
[li][purple]<div align="center">[/purple][/li]
[li][purple]  <center>[/purple][/li]
[li][purple]  <table border="1" cellspacing="1" width="100%" bordercolor="#000000">[/purple][/li]
[li][purple]    <tr>[/purple][/li]
[li][purple]      <td width="100%" bordercolor="#FFFFFF">[/purple][/li]
[li][purple]      <p><font face="Arial" size="3" color="#0000FF"><b>New Registration</b></font><font size="2" face="Arial"> - <b>Date/Time:</b> $date_time,<b> Name:</b> $title $first_name $last_name,<b> Email:</b> $email,<b> Username:</b> $choose_username</font></p>[/purple][/li]
[li][purple]      </td>[/purple][/li]
[li][purple]    </tr>[/purple][/li]
[li][purple]  </table>[/purple][/li]
[li][purple]  </center>[/purple][/li]
[li][purple]</div>[/purple][/li]
[li][purple][/purple][red])[/red][red];[/red][/li]
[li][black][b]print[/b][/black] LOG [red]"[/red][purple][blue]@log2[/blue][/purple][red]"[/red][red];[/red][/li]
[li][black][b]close[/b][/black] [red]([/red]LOG[red])[/red][red];[/red][/li]
[li][gray][i]####################[/i][/gray][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$confirmation_email_print[/blue][red])[/red][red];[/red][/li]
[li][gray][i]## Confirmation email[/i][/gray][/li]
[li][blue]$confirmation_email_print[/blue] = [red]"[/red][purple][/purple][/li]
[li][purple]Dear [blue]$first_name[/blue],[purple][b]\n[/b][/purple][/purple][/li]
[li][purple]Thank you for registering with Medical-Book.co.uk.[/purple][/li]
[li][purple]Login URL: [URL unfurl="true"]http://medical-book.co.uk/Login_And_Register/Login.htm[/URL][purple][b]\n[/b][/purple][/purple][/li]
[li][purple]Username:   [blue]$choose_username[/blue][/purple][/li]
[li][purple]Password:   [blue]$choose_password[/blue][purple][b]\n[/b][/purple][/purple][/li]
[li][purple]> Medical-Book.co.uk ( [blue]$date_time[/blue] ) <[/purple][red]"[/red][red];[/red][/li]
[li][/li]
[li][gray][i]## Send confirmation email[/i][/gray][/li]
[li][black][b]use[/b][/black] [green]MIME::Lite[/green][red];[/red][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$confirmation_email[/blue][red])[/red][red];[/red][/li]
[li][blue]$confirmation_email[/blue] = MIME::Lite->[maroon]new[/maroon][red]([/red][purple]From[/purple]    => [red]'[/red][purple]Medical-Book.co.uk[/purple][red]'[/red],[/li]
[li]				      [purple]To[/purple]      => [red]"[/red][purple][blue]$email[/blue][/purple][red]"[/red],[/li]
[li]                                      [purple]Subject[/purple] => [red]'[/red][purple]Registration Confirmation[/purple][red]'[/red],[/li]
[li]                                      [purple]Type[/purple]    => [red]'[/red][purple]multipart/mixed[/purple][red]'[/red][red])[/red][red];[/red][/li]
[li]          [blue]$confirmation_email[/blue]->[maroon]attach[/maroon][red]([/red][purple]Type[/purple]    => [red]'[/red][purple]TEXT[/purple][red]'[/red],[/li]
[li]                                      [purple]Data[/purple]    => [red]"[/red][purple][blue]$confirmation_email_print[/blue][/purple][red]"[/red][red])[/red][red];[/red][/li]
[li][/li]
[li][blue]$confirmation_email[/blue]->[maroon]send[/maroon][red]([/red][red])[/red][red];[/red][/li]
[li][gray][i]####################[/i][/gray][/li]
[li][/li]
[li][gray][i]####################[/i][/gray][/li]
[li][gray][i]## Confirmation page[/i][/gray][/li]
[li][black][b]use[/b][/black] [green]HTML::Template[/green][red];[/red][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$template[/blue][red])[/red][red];[/red][/li]
[li][blue]$template[/blue] = HTML::Template->[maroon]new[/maroon][red]([/red][purple]filename[/purple] => [red]"[/red][purple]Register_Complete.htm[/purple][red]"[/red][red])[/red][red];[/red][/li]
[li][black][b]print[/b][/black] [red]"[/red][purple]Content-Type: text/html[purple][b]\n[/b][/purple][purple][b]\n[/b][/purple][/purple][red]"[/red], [blue]$template[/blue]->[maroon]output[/maroon][red];[/red][/li]
[li][gray][i]####################[/i][/gray][/li]
[li][red]}[/red][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$field_failed_counter[/blue], [blue]$reg_failed_message[/blue][red])[/red][red];[/red][/li]
[li][gray][i]##### VALIDATION FAIL[/i][/gray][/li]
[li][olive][b]if[/b][/olive] [red]([/red][blue]$validate_counter[/blue] != [fuchsia]19[/fuchsia][red])[/red] [red]{[/red][/li]
[li][blue]$field_failed_counter[/blue] = [fuchsia]19[/fuchsia] - [blue]$validate_counter[/blue][red];[/red][/li]
[li][blue]$reg_failed_message[/blue] = [red]qq([/red][purple]<p><font face="Arial" size="2"><b>Registration form completed incorrectly. Please check the following:</b></font></p>[/purple][red])[/red][red];[/red][/li]
[li][black][b]use[/b][/black] [green]HTML::Template[/green][red];[/red][/li]
[li][black][b]my[/b][/black] [red]([/red][blue]$template2[/blue][red])[/red][red];[/red][/li]
[li][blue]$template2[/blue] = HTML::Template->[maroon]new[/maroon][red]([/red][purple]filename[/purple] => [red]"[/red][purple]Register_Failed.htm[/purple][red]"[/red][red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]REGFAILEDMESSAGE[/purple] => [red]"[/red][purple][blue]$reg_failed_message[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE1[/purple] =>  [red]"[/red][purple][blue]$validate_1_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT1[/purple]    =>  [red]"[/red][purple][blue]$choose_username[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE1B[/purple] => [red]"[/red][purple][blue]$validate_1b_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE2[/purple] =>  [red]"[/red][purple][blue]$validate_2_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE3[/purple] =>  [red]"[/red][purple][blue]$validate_3_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE4[/purple] =>  [red]"[/red][purple][blue]$validate_4_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE5[/purple] =>  [red]"[/red][purple][blue]$validate_5_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT5[/purple]    =>  [red]"[/red][purple][blue]$other_title[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE6[/purple] =>  [red]"[/red][purple][blue]$validate_6_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT6[/purple]    =>  [red]"[/red][purple][blue]$first_name[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE7[/purple] =>  [red]"[/red][purple][blue]$validate_7_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT7[/purple]    =>  [red]"[/red][purple][blue]$last_name[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE8[/purple] =>  [red]"[/red][purple][blue]$validate_8_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT8[/purple]    =>  [red]"[/red][purple][blue]$email[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE9[/purple] =>  [red]"[/red][purple][blue]$validate_9_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT9[/purple]    =>  [red]"[/red][purple][blue]$confirm_email[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE10[/purple] => [red]"[/red][purple][blue]$validate_10_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT10[/purple]    => [red]"[/red][purple][blue]$address_1[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE11[/purple] => [red]"[/red][purple][blue]$validate_11_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT11[/purple]    => [red]"[/red][purple][blue]$address_2[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE12[/purple] => [red]"[/red][purple][blue]$validate_12_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT12[/purple]    => [red]"[/red][purple][blue]$town_city[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE13[/purple] => [red]"[/red][purple][blue]$validate_13_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT13[/purple]    => [red]"[/red][purple][blue]$county[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE14[/purple] => [red]"[/red][purple][blue]$validate_14_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT14[/purple]    => [red]"[/red][purple][blue]$postcode[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE15[/purple] => [red]"[/red][purple][blue]$validate_15_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE16[/purple] => [red]"[/red][purple][blue]$validate_16_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT16[/purple]    => [red]"[/red][purple][blue]$telephone[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE17[/purple] => [red]"[/red][purple][blue]$validate_17_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PRINT17[/purple]    => [red]"[/red][purple][blue]$fax[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][blue]$template2[/blue]->[maroon]param[/maroon] [red]([/red] [purple]VALIDATE18[/purple] => [red]"[/red][purple][blue]$validate_18_warn[/blue][/purple][red]"[/red] [red])[/red][red];[/red][/li]
[li][/li]
[li][black][b]print[/b][/black] [red]"[/red][purple]Content-Type: text/html[purple][b]\n[/b][/purple][purple][b]\n[/b][/purple][/purple][red]"[/red], [blue]$template2[/blue]->[maroon]output[/maroon][red];[/red][/li]
[li][red]}[/red][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[li][gray][i]## END CHECK SCRIPT WAS EXECUTED FROM REGISTRATION FORM[/i][/gray][/li]
[li][red]}[/red][/li]
[li][olive][b]else[/b][/olive] [red]{[/red][/li]
[li][black][b]print[/b][/black] [red]"[/red][purple]Content-type: text/html[purple][b]\n[/b][/purple][purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red][/li]
[li][black][b]print[/b][/black] [red]qq([/red][purple]<font face="arial" size="2">$execution_check_m</font>[/purple][red])[/red][red];[/red][/li]
[li][red]}[/red][/li]
[li][gray][i]#######################################[/i][/gray][/li]
[/ol]
[tt]------------------------------------------------------------
Pragmas (perl 5.8.8) used :
[ul]
[li]diagnostics - Produce verbose warning diagnostics[/li]
[li]strict - Perl pragma to restrict unsafe constructs[/li]
[li]warnings - Perl pragma to control optional warnings[/li]
[/ul]
Core (perl 5.8.8) Modules used :
[ul]
[li]CGI - Simple Common Gateway Interface Class[/li]
[/ul]
Other Modules used :
[ul]
[li]HTML::Template[/li]
[li]HTML::Template[/li]
[li]MIME::Lite[/li]
[/ul]
[/tt]

Chris
 
I guess my post was too long...

Complete code

Code:
#! /usr/bin/perl
use strict;
use CGI ':standard';
use diagnostics;
use warnings;
print "Content-type: text/html\n\n";

##### MODULES USED >>>>> | strict | CGI ':standard' | diagnostics | warnings | Mime::Lite | HTML::Template |

#######################################
my ($date_time);
my ($sec, $min, $hour, $mday, $mon, $year)=gmtime;
##### DATE/TIME
$date_time = sprintf ('%02d/%02d/%4d - %02d:%02d:%02d', $mday, $mon+1, $year+1900, $hour, $min, $sec);
#######################################

#######################################
my ($validate_counter, $secure_path, $users_folder_path, $event_log_path, $profile_file_name, $subscriptions_file_name, $d_subscriptions_file_loc);
##### INITIAL VALUES - ## 1, validation counter initial value - ## 2, path to secure directory - ## 3, path to users directory - ## 4, path to events log file - ## 5, profile file name - ## 6, subscriptions file name - ## 7, default subscriptions file path
## 1
$validate_counter = 		0;
## 2
$secure_path = 			"/PATH/";
## 3
$users_folder_path = 		"Users/";
## 4
$event_log_path =               "Admin/Logs/Event_Log/event_log.htm";
## 5
$profile_file_name =      	"/profile.txt";
## 6
$subscriptions_file_name =      "/subscriptions.txt";
## 7
$d_subscriptions_file_loc =     "Default_Subscriptions_File/default_subscriptions.txt";
#######################################

#######################################
##### FAILED VALIDATION MESSAGES
my ($execution_check_m);
## EXECUTION CHECK
$execution_check_m = 		'Illegal Access';

my ($html_begin, $html_end);
## HTML Tags
$html_begin = 			qq(<font size="2" color="#FF0000" face="Arial"><LI>);
$html_end = 			qq(<br></font>);

my ($choose_username_m, $choose_usernameb_m, $choose_password_m, $confirm_password_m, $title_m, $other_title_m, $first_name_m, $last_name_m, $email_m, $confirm_email_m, $address_1_m, $address_2_m, $town_city_m, $county_m, $postcode_m, $country_m, $telephone_m, $fax_m, $accept_terms_m);
## MESSAGES
$choose_username_m = 		'Choose A Username - Username must be 4-20 characters long (a-z, 0-9, _ ONLY).';
$choose_usernameb_m = 		'Choose A Username - This Username already exists. Please choose another.';
$choose_password_m = 		'Choose A Password - Password must be atleast 8 chracters long.';
$confirm_password_m = 		'Confirm Your password - Does not match your Password.';
$title_m = 			'Title - Choose one.';
$other_title_m = 		'Other Title - If Title=Other, please specify (a-z, A-Z ONLY).';
$first_name_m = 		'First Name - First Name must be no more than 40 characters long (a-z, A-Z ONLY).';
$last_name_m = 			'Last Name - Last Name must be no more than 40 characters long (a-z, A-Z ONLY).';
$email_m = 			'Email Address - I.E. email@domain.com.';
$confirm_email_m =		'Confirm Email Address - Does not match your Email.';
$address_1_m = 			'Address Line 1 - (a-z, A-Z, 0-9 ONLY).';
$address_2_m = 			'Address Line 2 - (a-z, A-Z, 0-9 ONLY).';
$town_city_m = 			'Town/City - (a-z, A-Z, ONLY).';
$county_m = 			'County - (a-z, A-Z, ONLY).';
$postcode_m = 			'Postcode - (a-z, A-Z, 0-9 ONLY).';
$country_m = 			'Country - Choose one.';
$telephone_m = 			'Telephone - Telephone must be exactly 11 numbers long (0-9, +s ONLY).';
$fax_m = 			'Fax - Fax must be exactly 11 numbers long (0-9, +s ONLY).';
$accept_terms_m = 		'Accept Terms And Conditions - Checkbox has now been ticked. Untick if you do not accept the Terms And Conditions.';
#######################################

#######################################
my ($choose_username, $choose_password, $confirm_password, $title, $other_title, $first_name, $last_name, $email, $confirm_email, $address_1, $address_2, $town_city, $county, $postcode, $country, $telephone, $fax, $accept_terms, $execution_check);
##### CONNECT TO REGISTRATION FORM
$choose_username = 		param('choose_username');
$choose_password = 		param('choose_password');
$confirm_password =		param('confirm_password');
$title = 			param('title');
$other_title = 			param('other_title');
$first_name = 			param('first_name');
$last_name = 			param('last_name');
$email = 			param('email');
$confirm_email = 		param('confirm_email');
$address_1 = 			param('address_1');
$address_2 = 			param('address_2');
$town_city = 			param('town_city');
$county = 			param('county');
$postcode = 			param('postcode');
$country = 			param('country');
$telephone = 			param('telephone');
$fax = 				param('fax');
$accept_terms = 		param('accept_terms');
$execution_check = 		param('execution_check');
#######################################

#######################################
## CHECK SCRIPT WAS EXECUTED FROM REGISTRATION FORM
if ($execution_check == 1) {
#######################################

#######################################
## VARIABLE CONVERSIONS
## Change choose_username to lowercase characters
$choose_username = lc($choose_username);

#######################################

#######################################
my ($validate_1_warn, $validate_1b_warn, $validate_2_warn, $validate_3_warn, $validate_4_warn, $validate_5_warn, $validate_6_warn, $validate_7_warn, $validate_8_warn, $validate_9_warn, $validate_10_warn, $validate_11_warn, $validate_12_warn, $validate_13_warn, $validate_14_warn, $validate_15_warn, $validate_16_warn, $validate_17_warn, $validate_18_warn);
##### VALIDATE REGISTRATION FORM
####################################### 1
##Regex## choose_username
if ($choose_username =~ //) { 
	$validate_counter++ 
}
else { 
	$validate_1_warn = qq($html_begin$choose_username_m$html_end); 
}
####################################### 2 
if (-d "$secure_path$users_folder_path$choose_username") { 
	$validate_1b_warn = qq($html_begin$choose_usernameb_m$html_end) 
} 
else { 
	$validate_counter++ 
}
####################################### 3
##Regex## choose_password
if ($choose_password =~ //) { 
	$validate_counter++ 
} 
else { 
	$validate_2_warn = qq($html_begin$choose_password_m$html_end); 
}
####################################### 4
## confirm_password
if ($confirm_password eq "$choose_password") { 
	$validate_counter++ 
} 
else { 
	$validate_3_warn = qq($html_begin$confirm_password_m$html_end); 
}
####################################### 5
## title
if ($title != "1") { 
	$validate_counter++ 
} 
else { 
	$validate_4_warn = qq($html_begin$title_m$html_end); 
}
####################################### 6
##Regex## other_title
if ($title eq "Other") { 
	if ($other_title =~ //) { 
		$validate_counter++ }
	else { 
		$validate_5_warn = qq($html_begin$other_title$html_end); 
	} 
}
else { 
	$validate_17_warn = "";
	$validate_counter++ 
}
if ($title ne "Other") { 
	$other_title = ""; 
}
####################################### 7
##Regex## first_name
if ($first_name =~ //) { 
	$validate_counter++ 
}
else { 
	$validate_6_warn = qq($html_begin$first_name_m$html_end); 
}
####################################### 8
##Regex## last_name
if ($last_name =~ //) { 
	$validate_counter++; 
} 
else { 
	$validate_7_warn = qq($html_begin$last_name_m$html_end); 
}
####################################### 9
##Regex## email
if ($email =~ //) { 
	$validate_counter++ 
} 
else { 
	$validate_8_warn = qq($html_begin$email_m$html_end); 
}
####################################### 10
## confirm_email
if ($confirm_email eq "$email") { 
	$validate_counter++ 
} 
else { 
	$validate_9_warn = qq($html_begin$confirm_email_m$html_end); 
}
####################################### 11
##Regex## address_1
if ($address_1 =~ //) {
	$validate_counter++ 
} 
else { 
	$validate_10_warn = qq($html_begin$address_1_m$html_end); 
}
####################################### 12
##Regex## address_2
if ($address_2 =~ //) { 
	$validate_counter++ 
} 
else { 
	$validate_11_warn = qq($html_begin$address_2_m$html_end); 
}
if ($address_2 eq "") { 
	$validate_counter++; $validate_11_warn = ""; 
}
####################################### 13
##Regex## town_city
if ($town_city =~ //) { 
	$validate_counter++ 
} 
else { 
	$validate_12_warn = qq($html_begin$town_city_m$html_end); 
}
####################################### 14
##Regex## county
if ($county =~ //) { 
	$validate_counter++ 
} 
else { 
	$validate_13_warn = qq($html_begin$county_m$html_end); 
}
if ($county eq "") { 
	$validate_counter++; $validate_13_warn = ""; 
}
####################################### 15
##Regex## postcode
if ($postcode =~ //) { 
	$validate_counter++ 
} 
else { 
	$validate_14_warn = qq($html_begin$postcode_m$html_end); 
}
####################################### 16
## country
if ($country != "1") { 
	$validate_counter++ 
} 
else { 
	$validate_15_warn = qq($html_begin$country_m$html_end); 
}
####################################### 17
##Regex## telephone
if ($telephone =~ //) { 
	$validate_counter++ 
} 
else { 
	$validate_16_warn = qq($html_begin$telephone_m$html_end); 
}
####################################### 18
##Regex## fax
if ($fax =~ //) { 
	$validate_counter++ 
} 
else { 
	$validate_17_warn = qq($html_begin$fax_m$html_end); 
}
if ($fax eq "") { 
	$validate_counter++; $validate_17_warn = ""; 
}
####################################### 19
my ($accept_terms_length);
## accept_terms
$accept_terms_length = length ($accept_terms);
if ($accept_terms_length == "1") {
	$validate_counter++
} 
else {
	$validate_18_warn = qq($html_begin$accept_terms_m$html_end); 
}
#######################################

#######################################
#### VALIDATION PASS
if ($validate_counter == 19) {

####################
##### IF A NON-COMPULSORY FIELD IS BLANK, FILL IT WITH "None"
if ($other_title eq "") { $other_title = "None"; }
if ($address_2 eq "") { $address_2 = "None"; }
if ($county eq "") { $county = "None"; }
if ($fax eq "") { $fax = "None"; }

####################
## Create user folder
mkdir ("$secure_path$users_folder_path$choose_username", 0777) || die "Cannot Open: $secure_path$users_folder_path$choose_username";

## Create a new profile in user folder
open (LOG, ">$secure_path$users_folder_path$choose_username$profile_file_name") || die "Cannot open: $secure_path$users_folder_path$choose_username$profile_file_name";
flock (LOG, 2) || die "Cannot flock: $secure_path$users_folder_path$choose_username$profile_file_name";
print LOG "$choose_username|$choose_password|$title|$other_title|$first_name|$last_name|$email|$address_1|$address_2|$town_city|$county|$postcode|$country|$telephone|$fax|$accept_terms|$execution_check";
close (LOG)

## Create a subscriptions file in user folder and copy contents of default subscriptions file
open (LOG, "<$secure_path$d_subscriptions_file_loc") || die "Cannot open: $secure_path$d_subscriptions_file_loc";
flock (LOG, 2) || die "Cannot flock: $secure_path$d_subscriptions_file_loc";
my @log1 = <LOG>;
close (LOG) || die "Cannot close: $secure_path$d_subscriptions_file_loc";

open (LOG, ">$secure_path$users_folder_path$choose_username$subscriptions_file_name") || die "Cannot open: $secure_path$users_folder_path$choose_username$subscriptions_file_name";
flock (LOG, 2) || die "Cannot flock: $secure_path$users_folder_path$choose_username$subscriptions_file_name";
print LOG "@log1";
close (LOG);
####################
## Log new event
open (LOG, "<$secure_path$event_log_path") || die "Cannot open: $secure_path$event_log_path";
flock (LOG, 2) || die "Cannot flock: $secure_path$event_log_path";
my @log2 = <LOG>;
close (LOG) || die "Cannot close: $secure_path$event_log_path";

open (LOG, ">$secure_path$event_log_path") || die "Cannot open: $secure_path$event_log_path";
flock (LOG, 2) || die "Cannot flock: $secure_path$event_log_path";
print LOG qq(
<div align="center">
  <center>
  <table border="1" cellspacing="1" width="100%" bordercolor="#000000">
    <tr>
      <td width="100%" bordercolor="#FFFFFF">
      <p><font face="Arial" size="3" color="#0000FF"><b>New Registration</b></font><font size="2" face="Arial"> - <b>Date/Time:</b> $date_time,<b> Name:</b> $title $first_name $last_name,<b> Email:</b> $email,<b> Username:</b> $choose_username</font></p>
      </td>
    </tr>
  </table>
  </center>
</div>
);
print LOG "@log2";
close (LOG);
####################
my ($confirmation_email_print);
## Confirmation email
$confirmation_email_print = "
Dear $first_name,\n
Thank you for registering with Medical-Book.co.uk.
Login URL: [URL unfurl="true"]http://medical-book.co.uk/Login_And_Register/Login.htm\n[/URL]
Username:   $choose_username
Password:   $choose_password\n
> Medical-Book.co.uk ( $date_time ) <";

## Send confirmation email
use MIME::Lite;
my ($confirmation_email);
$confirmation_email = MIME::Lite->new(From    => 'Medical-Book.co.uk',
				      To      => "$email",
                                      Subject => 'Registration Confirmation',
                                      Type    => 'multipart/mixed');
          $confirmation_email->attach(Type    => 'TEXT',
                                      Data    => "$confirmation_email_print");

$confirmation_email->send();
####################

####################
## Confirmation page
use HTML::Template;
my ($template);
$template = HTML::Template->new(filename => "Register_Complete.htm");
print "Content-Type: text/html\n\n", $template->output;
####################
}
#######################################

#######################################
my ($field_failed_counter, $reg_failed_message);
##### VALIDATION FAIL
if ($validate_counter != 19) {
$field_failed_counter = 19 - $validate_counter;
$reg_failed_message = qq(<p><font face="Arial" size="2"><b>Registration form completed incorrectly. Please check the following:</b></font></p>);
use HTML::Template;
my ($template2);
$template2 = HTML::Template->new(filename => "Register_Failed.htm");
$template2->param ( REGFAILEDMESSAGE => "$reg_failed_message" );

$template2->param ( VALIDATE1 =>  "$validate_1_warn" );
$template2->param ( PRINT1    =>  "$choose_username" );
$template2->param ( VALIDATE1B => "$validate_1b_warn" );
$template2->param ( VALIDATE2 =>  "$validate_2_warn" );
$template2->param ( VALIDATE3 =>  "$validate_3_warn" );
$template2->param ( VALIDATE4 =>  "$validate_4_warn" );
$template2->param ( VALIDATE5 =>  "$validate_5_warn" );
$template2->param ( PRINT5    =>  "$other_title" );
$template2->param ( VALIDATE6 =>  "$validate_6_warn" );
$template2->param ( PRINT6    =>  "$first_name" );
$template2->param ( VALIDATE7 =>  "$validate_7_warn" );
$template2->param ( PRINT7    =>  "$last_name" );
$template2->param ( VALIDATE8 =>  "$validate_8_warn" );
$template2->param ( PRINT8    =>  "$email" );
$template2->param ( VALIDATE9 =>  "$validate_9_warn" );
$template2->param ( PRINT9    =>  "$confirm_email" );
$template2->param ( VALIDATE10 => "$validate_10_warn" );
$template2->param ( PRINT10    => "$address_1" );
$template2->param ( VALIDATE11 => "$validate_11_warn" );
$template2->param ( PRINT11    => "$address_2" );
$template2->param ( VALIDATE12 => "$validate_12_warn" );
$template2->param ( PRINT12    => "$town_city" );
$template2->param ( VALIDATE13 => "$validate_13_warn" );
$template2->param ( PRINT13    => "$county" );
$template2->param ( VALIDATE14 => "$validate_14_warn" );
$template2->param ( PRINT14    => "$postcode" );
$template2->param ( VALIDATE15 => "$validate_15_warn" );
$template2->param ( VALIDATE16 => "$validate_16_warn" );
$template2->param ( PRINT16    => "$telephone" );
$template2->param ( VALIDATE17 => "$validate_17_warn" );
$template2->param ( PRINT17    => "$fax" );
$template2->param ( VALIDATE18 => "$validate_18_warn" );

print "Content-Type: text/html\n\n", $template2->output;
}
#######################################

#######################################
## END CHECK SCRIPT WAS EXECUTED FROM REGISTRATION FORM
}
else {
print "Content-type: text/html\n\n";
print qq(<font face="arial" size="2">$execution_check_m</font>);
}
#######################################
 
Been trying to work this one out for hours! Any help would be greatly appreciated.

Thanks, Chris
 
check your webserver's error logs, and add this line to the top of your script
use CGI::Carp qw/fatalsToBrowser/;

That'll give you more information on what's actually causing the problem

HTH
--Paul

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
One obvious error:

close (LOG)

around line 300, no semi-colon at the end of the line.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Chris,

Don't quote single scalars:

Code:
To      => "$email",

should be:

Code:
To      => $email,

Bad habit. I thought I had mentioned this to you a couple of times. Using quotes needlessly slows down perl scripts and can introduce hard to find bugs.

You have many instances of quoting scalars needlessly in the code you posted:

Code:
$template2->param ( VALIDATE1 =>  "$validate_1_warn" );
$template2->param ( PRINT1    =>  "$choose_username" );
$template2->param ( VALIDATE1B => "$validate_1b_warn" );
and many more follow

Declaring your variables only to define them in the next line is also totally unnecessary, for example:

Code:
[red]my ($date_time);[/red]
my ($sec, $min, $hour, $mday, $mon, $year)=gmtime;
##### DATE/TIME
[red]$date_time[/red] = sprintf ('%02d/%02d/%4d - %02d:%02d:%02d', $mday, $mon+1, $year+1900, $hour, $min, $sec);

better written as:

Code:
my ($sec, $min, $hour, $mday, $mon, $year)=gmtime;
##### DATE/TIME
[red]my $date_time[/red] = sprintf ('%02d/%02d/%4d - %02d:%02d:%02d', $mday, $mon+1, $year+1900, $hour, $min, $sec);

and there is also no need to put parenthesis around a single scalar to declare it:

Code:
my ($date_time);

should be:

Code:
my $date_time;

putting parenthesis around it just creates a list with one element. I don't think it hurts anything but it is not necessary if thats what you are maybe thinking.

Another thing that will help your perl scripts to run efficiently is to use the proper quotes. Single quotes or q{} for strings without any meta characters, such as:

Code:
$html_begin =             qq(<font size="2" color="#FF0000" face="Arial"><LI>);
$html_end =             qq(<br></font>);

when you use double-quotes or qq{} perl is forced to check the string for meta characters.



------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Hey Kevin,

Thank you very, very, very much. I fixed the close log and it is working again. Also, i'm very grateful to you for looking through my script and providing some tips. I will take a look through and fix all the little issues immediately. And I promise not to make the same mistakes again :).

Paul, thanks for advice on CGI Carp. When I was trying to debug the script I did actually use CGI Carp but I removed it earlier. However, I am still very uncertain on how to actually view the errors, I have absolutely no idea, therefore I never actually use any of the debugging tools (i.e. warnings, diagnostics etc etc).

Chris
 
Before I forgot...

The script below checks all the users files and opens each users profile. If the email typed in matches the email in the file, then it will email the user their username and password. Works fine, however the user is sent 2 emails instead of 1. Any particular reason why? There is no reason why a users folder should be looped through twice that I can see?

Chris

Code:
[gray]#! /usr/bin/perl[/gray]
[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]strict[/green][red];[/red]
[black][b]use[/b][/black] [green]CGI[/green] [red]'[/red][purple]:standard[/purple][red]'[/red][red];[/red]
[black][b]use[/b][/black] [green]diagnostics[/green][red];[/red]
[black][b]use[/b][/black] [green]warnings[/green][red];[/red]

[gray][i]##### MODULES USED >>>>> | strict | CGI ':standard' | diagnostics | warnings | Mime::Lite | HTML::Template |[/i][/gray]

[gray][i]#######################################[/i][/gray]
[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [red]([/red][blue]$execution_check[/blue], [blue]$execution_check_m[/blue][red])[/red][red];[/red]
[black][b]my[/b][/black] [red]([/red][blue]$email[/blue], [blue]$path_to_users_file[/blue], [blue]$date_time[/blue], [blue]$email_no[/blue], [blue]$first_name_no[/blue], [blue]$username_no[/blue], [blue]$password_no[/blue], [blue]$send_email[/blue], [blue]$send_first_name[/blue], [blue]$send_username[/blue], [blue]$send_password[/blue], [blue]$pass_fail[/blue], [blue]$pass_fail_check[/blue], [blue]$f_u_p_message[/blue], [blue]$f_u_p[/blue], [blue]$template[/blue][red])[/red][red];[/red]
[black][b]my[/b][/black] [red]([/red][blue]@directory_contents[/blue], [blue]@log[/blue], [blue]@split_log[/blue][red])[/red][red];[/red]
[gray][i]#######################################[/i][/gray]
[blue]$email[/blue] = [maroon]param[/maroon][red]([/red][red]'[/red][purple]email[/purple][red]
'[/red][red])[/red][red];[/red]
[blue]$execution_check[/blue] = [maroon]param[/maroon][red]([/red][red]'[/red][purple]execution_check
[/purple][red]'[/red][red])[/red][red];[/red]
[gray][i]#######################################[/i][/gray]
[blue]$path_to_users_file[/blue] = [red]"[/red][purple]/PATH	/[/purple][red]"[/red][red];[/red]
[gray][i]#######################################[/i][/gray]
[black][b]my[/b][/black] [red]([/red][blue]$sec[/blue], [blue]$min[/blue], [blue]$hour[/blue], [blue]$mday[/blue], [blue]$mon[/blue], [blue]$year[/blue][red])[/red]=[url=http://perldoc.perl.org/functions/gmtime.html][black][b]gmtime[/b][/black]
[/url][red];[/red]
[blue]$date_time[/blue] = [url=http://perldoc.perl.org/functions/sprintf.html][black][b]sprintf[/b]
[/black][/url] [red]([/red][red]'[/red][purple]%02d/%02d/%4d - %02d:%02d:%02d[/purple][red]'[/red], [blue]$mday[/blue], [blue]$mon[/blue]+[fuchsia]1[/fuchsia], [blue]$year[/blue]+[fuchsia]1900[/fuchsia], [blue]$hour[/blue], [blue]$min[/blue], [blue]$sec[/blue][red])[/red][red];[/red]
[gray][i]#######################################[/i][/gray]
[blue]$execution_check_m[/blue] = [red]'[/red][purple]Illegal Access[/purple][red]'[/red][red];[/red]
[gray][i]#######################################[/i][/gray]
[blue]$email_no[/blue] =      [fuchsia]6[/fuchsia][red];[/red]
[blue]$first_name_no[/blue] = [fuchsia]4[/fuchsia][red];[/red]
[blue]$username_no[/blue] =   [fuchsia]0[/fuchsia][red];[/red]
[blue]$password_no[/blue] =   [fuchsia]1[/fuchsia][red];[/red]
[gray][i]#######################################[/i][/gray]

[gray][i]#######################################[/i][/gray]
[gray][i]## CHECK SCRIPT WAS EXECUTED FROM REQUEST FORM[/i][/gray]
[olive][b]if[/b][/olive] [red]([/red][blue]$execution_check[/blue] == [fuchsia]1[/fuchsia][red])[/red] [red]{[/red]
[gray][i]#######################################[/i][/gray]

[url=http://perldoc.perl.org/functions/opendir.html][black][b]opendir[/b]
[/black][/url] [red]([/red]FILE, [red]"[/red][purple][blue]$path_to_users_file[/blue][/purple][red]"[/red]
[red])[/red] || [url=http://perldoc.perl.org/functions/die.html][black][b]die[/b][/black][/url] [red]"[/red][purple]Cannot open: [blue]$path_to_users_file[/blue][/purple][red]"[/red][red];[/red]
[blue]@directory_contents[/blue] = [url=http://perldoc.perl.org/functions/grep.html][black][b]grep[/b][/black]
[/url] [red]{[/red]![red]/[/red][purple]^[purple][b]\.[/b][/purple]{1,2}$[/purple]
[red]/[/red][red]}[/red] [url=http://perldoc.perl.org/functions/readdir.html][black][b]readdir[/b]
[/black][/url] [red]([/red]FILE[red])[/red][red];[/red]
[url=http://perldoc.perl.org/functions/closedir.html][black][b]closedir[/b]
[/black][/url] [red]([/red]FILE[red])[/red][red];[/red]

[olive][b]foreach[/b][/olive] [red]([/red][blue]@directory_contents[/blue][red])[/red] [red]{[/red]

        	[url=http://perldoc.perl.org/functions/open.html][black][b]open[/b][/black]
[/url] [red]([/red]LOG, [red]"[/red][purple]<[blue]$path_to_users_file[/blue][blue]$_[/blue]/
profile.txt[/purple][red]"[/red][red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot open: [blue]$path_to_users_file[/blue][blue]$_[/blue]/profile.txt[/purple][red]
"[/red][red];[/red]
		[url=http://perldoc.perl.org/functions/flock.html][black][b]flock[/b][/black]
[/url] [red]([/red]LOG, [fuchsia]2[/fuchsia][red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot flock: [blue]$path_to_users_file[/blue][blue]$_[/blue]/profile.txt[/purple][red]
"[/red][red];[/red]
		[blue]@log[/blue] = <LOG>[red];[/red]
		[url=http://perldoc.perl.org/functions/close.html][black][b]close[/b][/black]
[/url] [red]([/red]LOG[red])[/red] || [black][b]die[/b][/black] [red]"[/red][purple]Cannot close: [blue]$path_to_users_file[/blue][blue]$_[/blue]/profile.txt[/purple][red]
"[/red][red];[/red]
                
                [blue]@split_log[/blue] = [url=http://perldoc.perl.org/functions/split.html][black][b]split[/b][/black]
[/url][red]([/red][red]/[/red][purple][purple][b]\|[/b][/purple][/purple]
[red]/[/red], [blue]$log[/blue][red][[/red][fuchsia]0[/fuchsia][red]][/red][red])[/red]
[red];[/red]

                [olive][b]if[/b][/olive] [red]([/red][blue]$split_log[/blue][red][[/red][blue]$email_no[/blue][red]]
[/red] eq [blue]$email[/blue][red])[/red] [red]{[/red]

                	[blue]$send_email[/blue] =      [blue]$split_log[/blue][red][[/red][blue]$email_no[/blue][red]][/red][red]
;[/red]
                        [blue]$send_first_name[/blue] = [blue]$split_log[/blue][red][[/red][blue]$first_name_no[/blue][red]][/red]
[red];[/red]
                        [blue]$send_username[/blue] =   [blue]$split_log[/blue][red][[/red][blue]$username_no[/blue][red]][/red]
[red];[/red]
                        [blue]$send_password[/blue] =   [blue]$split_log[/blue][red][[/red][blue]$password_no[/blue][red]][/red]
[red];[/red]

                        [gray][i]####################[/i][/gray]
			[blue]$f_u_p_message[/blue] = [red]"[/red][purple][/purple]
[purple]			Dear [blue]$send_first_name[/blue],[purple][b]\n[/b][/purple][/purple]
[purple]			Login URL: [URL unfurl="true"]http://medical-book.co.uk/Login_And_Register/Login.htm[/URL][purple][b]\n[/b]
[/purple][/purple]
[purple]			Username:   [blue]$send_username[/blue][/purple]
[purple]			Password:   [blue]$send_password[/blue][purple][b]\n[/b][/purple][/purple]
[purple]			> Medical-Book.co.uk ( [blue]$date_time[/blue] ) <[/purple][red]"[/red][red];[/red]

			[gray][i]## Send confirmation email[/i][/gray]
			[black][b]use[/b][/black] [green]MIME::Lite[/green][red];[/red]
			[blue]$f_u_p[/blue] = MIME::Lite->[maroon]new[/maroon][red]([/red][purple]From[/purple]    =>   [red]'[/red][purple]Medical-Book.co.uk[/purple][red]'[/red],
				      			      [purple]To[/purple]      => [red]"[/red][purple][blue]$send_email[/blue][/purple][red]"[/red],
                                                              [purple]Subject[/purple] => [red]'[/red][purple]Forgotten Username/Password[/purple][red]'[/red],
                                                              [purple]Type[/purple]    => [red]'[/red][purple]multipart/mixed[/purple][red]'[/red][red])[/red][red];
[/red]
          		          [blue]$f_u_p[/blue]->[maroon]attach[/maroon][red]([/red][purple]Type
[/purple]    =>   [red]'[/red][purple]TEXT[/purple][red]'[/red],
                                                              [purple]Data[/purple]    => [red]"[/red][purple][blue]$f_u_p_message[/blue][/purple][red]"[/red][red])
[/red][red];[/red]

			[blue]$f_u_p[/blue]->[maroon]send[/maroon][red]([/red][red])[/red][red];
[/red]
			[gray][i]####################[/i][/gray]
                        [blue]$pass_fail[/blue] = [red]qq([/red][purple]<font face="Arial" color="#008000" size="3"> Your Username/Password has been emailed to you...</font>[/purple][red])[/red][red];[/red]
                        [blue]$pass_fail_check[/blue] = [red]"[/red][purple]1[/purple][red]"[/red][red];[/red]
		[red]}[/red]
[red]}[/red]

[olive][b]if[/b][/olive] [red]([/red][blue]$pass_fail_check[/blue] != [red]"[/red][purple]1[/purple][red]"[/red][red])[/red] [red]{[/red]
	[blue]$pass_fail[/blue] = [red]qq([/red][purple]<font face="Arial" color="#FF0000" size="3"> Email Address does not exist...</font>[/purple][red])[/red][red];[/red]
[red]}[/red] 

[black][b]use[/b][/black] [green]HTML::Template[/green][red];[/red]
[blue]$template[/blue] = HTML::Template->[maroon]new[/maroon][red]([/red][purple]filename[/purple] => [red]"[/red][purple]Forgotten_Username_Password_Failed.htm[/purple][red]"
[/red][red])[/red][red];[/red]
[blue]$template[/blue]->[maroon]param[/maroon] [red]([/red] [purple]PASSFAIL[/purple] => [red]"[/red][purple][blue]$pass_fail[/blue][/purple][red]"[/red] [red])[/red][red];[/red]
[url=http://perldoc.perl.org/functions/print.html][black][b]print[/b][/black]
[/url] [red]"[/red][purple]Content-Type: text/html[purple][b]\n[/b][/purple][purple][b]\n[/b][/purple][/purple]
[red]"[/red], [blue]$template[/blue]->[maroon]output[/maroon][red];[/red]
[gray][i]#######################################[/i][/gray]
[gray][i]## END CHECK SCRIPT WAS EXECUTED FROM REQUEST FORM[/i][/gray]
[red]}[/red]
[olive][b]else[/b][/olive] [red]{[/red]
[black][b]print[/b][/black] [red]"[/red][purple]Content-type: text/html[purple][b]\n[/b][/purple][purple][b]\n[/b][/purple][/purple]
[red]"[/red][red];[/red]
[black][b]print[/b][/black] [red]qq([/red][purple]<font face="arial" size="2">$execution_check_m</font>[/purple][red])[/red][red];[/red]
[red]}[/red]
[gray][i]#######################################[/i][/gray]
[tt]------------------------------------------------------------
Pragmas (perl 5.8.8) used :
[ul]
[li]diagnostics - Produce verbose warning diagnostics[/li]
[li]strict - Perl pragma to restrict unsafe constructs[/li]
[li]warnings - Perl pragma to control optional warnings[/li]
[/ul]
Core (perl 5.8.8) Modules used :
[ul]
[li]CGI - Simple Common Gateway Interface Class[/li]
[/ul]
Other Modules used :
[ul]
[li]HTML::Template
[/li]
[li]MIME::Lite
[/li]
[/ul]
[/tt]
 
Please note that I don't want to exit the loops once the email has been found. Users can potentially use the same email for different accounts.

Chris
 
Must be something do with the loop:

foreach (@directory_contents) {

hard to say though from just looking at the code.

Why is your code formmated so strangely? For example:

Code:
opendir
(FILE, "$path_to_users_file"
) || die "Cannot open: $path_to_users_file";
@directory_contents = grep
{!/^\.{1,2}$
/} readdir
(FILE);
closedir
(FILE);


------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Evening Kevin,

I didn't notice that. Must have been the way it was interpretted. I copied it from notepad, which is formatted fine. Sorry about that. I've looked over and over again at the loop and i'm still confused.

The file structure is as follows

Users.dir
chris.dir
profile.txt
usertest1.dir
profile.txt
usertest2.dir
profile.txt
usertest3.dir
profile.txt

Inside each profile file is the information separated by | i.e. chris|password|Mr|Chris|Massey etc etc etc

Ill take another look, but hope that sort of helps in explaining the structure a bit more. Thanks
 
Right, I got it working now for some very strange reason. I changed two values which were simply the position of the email and first name in the file. However, I now no longer recieve 2 emails. There should be no reason why this has happened :s

Chris
 
I don't know Chris. You should add some print lines to the foreach loop so you can track the progress of the script while it's processing. You might be able to see what's going on that way.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
I meant its working fine now since I made those changes, even though there is no reason why it should work now and wasn't working before.

Chris
 
there's always a reason .. ;)

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top