Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-24-2006, 11:33 PM
WebProWorld Member
 

Join Date: Jan 2005
Location: Australia!
Posts: 58
webgurl RepRank 0
Default help needed with $message part of CGI script

I have a file upload script that sends you an email if someone uploads to your server. I
need to track who the uploaded files belong to and so I have a created a field in my form
named your_email. I want to be able to see their email address in the message part of the
email.

Here is part of the script:

sub send_mail {
my ($from_email, $from_name, $to_email, $to_name, $subject, $message ) = @_;

if(open(MAIL, "|$CONFIG{mailprogram} -t")) {
print MAIL "From: $from_email ($from_name)\n";
print MAIL "To: $to_email ($to_name)\n";
print MAIL "Subject: $subject\n";
print MAIL "$message\n\nSubmitter's IP Address : $ENV{REMOTE_ADDR}\n";
#### print MAIL Submitter's Email Address : $your_email"; ######
close MAIL;
return(1);
} else {
return;
}
}


As I am not a coder (obviously), I tried what I thought would be the code to use without
success.

print MAIL Submitter's Email Address : $your_email";

I really would appreciate any help with this one line of code. From your help I can then
add more fields if necessary.

Thank you
Reply With Quote
  #2 (permalink)  
Old 07-25-2006, 12:47 PM
Easywebdev's Avatar
WebProWorld Veteran
 

Join Date: Apr 2004
Posts: 328
Easywebdev RepRank 1
Default

You are missing a double quote.

print MAIL Submitter's Email Address : $your_email";

print MAIL "Submitter's Email Address : $your_email";

You may have to escape that single quote as well
print MAIL "Submitter\'s Email Address : $your_email";

Hth. Eamonn.
Reply With Quote
  #3 (permalink)  
Old 07-25-2006, 06:55 PM
WebProWorld Member
 

Join Date: Jan 2005
Location: Australia!
Posts: 58
webgurl RepRank 0
Default

Yes that I know - it was a typo and with the other double quote, it still does not work.

Here is the script here: http://webco.net.au/test.txt

Thanks to anyone who has a look for me!
Reply With Quote
  #4 (permalink)  
Old 07-25-2006, 08:03 PM
Easywebdev's Avatar
WebProWorld Veteran
 

Join Date: Apr 2004
Posts: 328
Easywebdev RepRank 1
Default

The subroutine send_mail has TWO declerations of it. Only the last will be used and it is not using the $your_mail variable.

Code:
#################################################################### 

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


sub send_mail {
my ($from_email, $from_name, $to_email, $to_name, $subject, $message ) = @_;

if(open(MAIL, "|$CONFIG{mailprogram} -t")) {
print MAIL "From: $from_email ($from_name)\n";
print MAIL "To: $to_email ($to_name)\n";
print MAIL "Subject: $subject\n";
print MAIL "$message\n\nSubmitter's IP Address : $ENV{REMOTE_ADDR}\nSubmitter's Email Address : $your_email\n";
close MAIL;
return(1);
} else {
return;
}
}

sub send_mail {
	my ($from_email, $from_name, $to_email, $to_name, $subject, $message ) = @_;
	
	if(open(MAIL, "|$CONFIG{mailprogram} -t")) {
		print MAIL "From: $from_email ($from_name)\n";
		print MAIL "To: $to_email ($to_name)\n";
		print MAIL "Subject: $subject\n";
		print MAIL "$message\n\nSubmitter's IP Address : $ENV{REMOTE_ADDR}";
		close MAIL;
		return(1);
	} else {
		return;
	}
}

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

####################################################################
Delete the second sub send_mail block.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0