PDA

View Full Version : Form handler problem


Martin46766474
04-04-2003, 03:49 AM
I am using a mail handler script that uses:

$to_address = "me\@my.com";

to set the destination email. But I want to grab an email address from a form instead. I tried:

$to_address = "$query->param('sentto')";

to use an address entered in the form but it doesn't work. What am I doing wrong? It seems to go through OK but it isn't received.



Cheers.

YUPAPA
04-04-2003, 05:02 AM
it is


$to_address = 'me@my.com';

# For Form:
$to_address = $query->param('sentto');

Martin46766474
04-04-2003, 11:06 AM
I tried that but it just throws up an Internal Server Error. It just doesn't want to use an email address from my form (the form calls the script - it isn't part of it). If I put the to email address in the script it works fine. It must be possible but I'm obviously missing something.

Any ideas?

Cheers.

YUPAPA
04-04-2003, 01:41 PM
Then it must be something wrong with


$to_address = $query->param('sentto');



You probably forgot to load the CGI.pm module

Martin46766474
04-04-2003, 02:07 PM
CGI.pm module? Not sure what you mean. All it is is a readily available cgi script that sends the contents of a form to the address set in the script. It uses $whatever = $query->param('formfieldname'); elsewhere to put other info in the email that is sent so I figured that I could use the same method to set the destination email address instead of it being preset in the script.

I can't see what the problem is between using:

$to_address = "me\@my.com";

and using:

$to_address = "$query->param('sentto')";

to get the address from the form (INPUT name="sentto" size="22" value="") instead. But it looks like it isn't that simple so I'm stumped.

Could it be that it's losing the backslash? I have displayed the variable before sending and it's fine but I'm wondering if it is removed somehow when it reaches the script. I tried escaping it with another backslash but that doesn't work either. How could I add a line that shows the variable wrapped in * symbols in the script so I can check it's as it should be?

Martin46766474
04-04-2003, 03:36 PM
Sorry - what I tried initially was almost right afterall (minus the quotes) but the line needed to be moved further into the script. Works fine now.

Thanks for the help.

Cheers.

bazz
04-08-2003, 12:30 AM
Martin46766474?

Could I trouble you to post where you got your script from. I am trying to get a script which will let me do this:

hyoperlink to the form from many pages and within the hyperlink, populate the destination of the form. I want to have one form (and its script) useable by many pages sending to many addresses. Is this what you got?

Thanx

Martin46766474
04-14-2003, 06:48 PM
Thought I'd replied to this.

No, that isn't quite what I have. But I think I got it from www.hotscripts.com so a search there will likely find something. Although I'm sure I've seen similar stuff here so you might want to search here first.

bazz
04-23-2003, 06:44 PM
Thanks