Gossamer Forum
Home : Products : DBMan : Installation :

Can anyone see what's wrong with this?

Quote Reply
Can anyone see what's wrong with this?
Hi,

Further to my posts of the last couple of days, I've written a sub which is called from a javascript window. As far as I can tell the sub is fine - but when I "post" or "get" to it, I get an "unrecognised operation" thingee.

Can anyone see what I'm doing wrong in the calling - or is their something else I have to define?

This is the sub:

sub send_message {
#---------
#Send Message to user Build 1
#---------

# my ($message, @lines, $line);
# my ($output, $status, $counter);

# Set the userid to the logged in user.
# if ($auth_user_field >= 0) {
# $in{$db_cols[$auth_user_field]} = $db_userid;
# }

$mailprog = "/var/qmail/bin/qmail-inject";


open (MAIL, "|$mailprog -t")
| | print "Can't start mail program";
print MAIL "To: Lmoss\@ihug.co.nz"; # $rec{'Email'}\n";
print MAIL "From: $in{'Name'} (Posted from $tft)\n";
print MAIL "Subject: A message from $in{'Name'} posted from $tft\n";
print MAIL "-" x 60 . "\n\n";

print MAIL "$FORM{'Message'}\n\n";

print MAIL "Some information about $in{'Name'}:\n\n";
print MAIL "Age: $in{'Age'}\n";
print MAIL "Sex: $in{'Sex'}\n";
print MAIL "City: $in{'City'}\n";
print MAIL "State: $in{'State'}\n";
print MAIL "Country: $in{'Country'}\n";
print MAIL "Height: $in{'Height'}\n";
print MAIL "Weight $in{'Weight'}\n";
print MAIL "Hair: $in{'Hair'}\n";
print MAIL "Eyes: $in{'Eyes'}\n";
print MAIL "Seeking: $in{'Seeking'}\n";
print MAIL "Comments: $in{'Comments'}\n";
print MAIL "Homepage: $in{'Homepage'}\n";
print MAIL "ICQ: $in{'ICQ'}\n\n";
print MAIL "-" x 60 . "\n\n";
print MAIL "To reply to this message, log on to $tft (http://tablefortwo.hypermart.net)\n";
print MAIL "and search for $in{'ID'} on the locator.\n\n";
foreach $line(@closing) {
print MAIL "$line";
}

print MAIL"\n\n";
close (MAIL);
}
#End of send_message
#--------------------------------------------

And this is the form that calls it:

<form action="$db_script_url" method="POST"> <input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<TEXTAREA NAME="Message" ROWS=6 COLS=45 WRAP="VIRTUAL"></TEXTAREA><p><input type="submit" Value="Send" name="send_message"> <input type="Reset" value="Clear"></form>

Sorry that it's so unclear Smile

Anyone got any ideas?


Quote Reply
Re: Can anyone see what's wrong with this? In reply to
Have you added into db.cgi something for send_message?

Something like:

elsif ($in{'send_message'}) { if ($per_admin) { &send_message; } else { &html_unauth; } }

Hope this helps,

Alex
Quote Reply
Re: Can anyone see what's wrong with this? In reply to
Alex,

Thanks - I've overlooked including that Smile

The program now calls the send_message sub fine, however, it seems to ignore all the code that prints an email and goes straight to the "succcessful send" sub I included (which shows up fine.) Can anyone see why the following code doesn't work? Also, should I be calling the send_message with a GET or POST?

sub send_message {
#---------
#Send Message to user Build 1
#---------


my ($message, @lines, $line);
my ($output, $status, $counter);

# Set the userid to the logged in user.
if ($auth_user_field >= 0) {
$in{$db_cols[$auth_user_field]} = $db_userid;
}


$mailprog = "/var/qmail/bin/qmail-inject";



open (MAIL, "|$mailprog -t")
&#0124; &#0124; print "Can't start mail program";
print MAIL "To: lmoss\@ihug.co.nz"; # $rec{'Email'}\n";
print MAIL "From: lmoss\@ihug.co.nz"; #$in{'Name'} (Posted from $tft)\n";
print MAIL "Subject: A message from"; # $in{'Name'} posted from $tft\n";
print MAIL "-" x 60 . "\n\n";

print MAIL "$FORM{'Message'}\n\n";

print MAIL "Some information about $in{'Name'}:\n\n";
print MAIL "Age: $in{'Age'}\n";
print MAIL "Sex: $in{'Sex'}\n";
print MAIL "City: $in{'City'}\n";
print MAIL "State: $in{'State'}\n";
print MAIL "Country: $in{'Country'}\n";
print MAIL "Height: $in{'Height'}\n";
print MAIL "Weight $in{'Weight'}\n";
print MAIL "Hair: $in{'Hair'}\n";
print MAIL "Eyes: $in{'Eyes'}\n";
print MAIL "Seeking: $in{'Seeking'}\n";
print MAIL "Comments: $in{'Comments'}\n";
print MAIL "Homepage: $in{'Homepage'}\n";
print MAIL "ICQ: $in{'ICQ'}\n\n";
print MAIL "-" x 60 . "\n\n";
print MAIL "To reply to this message, log on to $tft (http://tablefortwo.hypermart.net)\n";
print MAIL "and search for $in{'ID'} on the locator.\n\n";
foreach $line(@closing) {
print MAIL "$line";
}
print MAIL"\n\n";
close (MAIL);

&message_sent;
}
#End of send_message
#---------------------------------------------------------

Any help would be greatly appreciated!