Help,
I can't load the '%rec = &get_record($in{$db_key})' as a default or registered user. Only with my own records, when I will sent an email, the values are loaded.
What can be wrong??? I will post all my codes. Sorry for the scrolling...
#--------------------------------------
my ($message) = $_[0];
&html_print_headers;
%rec = &get_record($in{$db_key});
if ($in{'Userid'}) {
$in{'Userid'} = $db_userid;
my ($status,@hits) = &query("view");
$in{'email'} = $hits[17];
$in{'name'} = $hits[22];
$in{'place'} = $hits[23];
$in{'phone'} = $hits[24];
$in{'emailmessage'} =
"Geachte $rec{'Naam'},
Kunt u met mij contact opnemen i.v.m. uw auto,
de $rec{'Merk'} $rec{'Type'}.
Alvast bedankt voor de moeite en tot ziens!!
Hoogachtend, $in{'name'}
$in{'phone'}
$in{'place'}
==============";
}
# <-- top of page formatting -->
print qq|
<html><head><title>$html_title: Email versturen</title></head>
<body bgcolor="#FFFFFF">
<center>
<table border=1 bgcolor="#D2FFD2" cellpadding=5 cellspacing=3 width=485 align=center valign=top>
<tr><td colspan=2 border=0 bgcolor="#006200">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Email versturen</b></td></tr>
<tr><td><p><center><$font_title><b>Email sturen</b></font></center><br>|;
# <-- introductory text -->
if ($message) { print qq|Los de fouten op:<br><font color="red"><$message|; }
print qq|<center>
<$font>Vul hier het Onderwerp in en de boodschap die verzonden moet worden aan <b>$rec{'Naam'}</b>.</font>
|;
# <-- email form -->
$in{'subject'} = "Re:$rec{'Merk'} $rec{'Type'}.";
print qq|
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="$db_key" value="$in{$db_key}">
<table>
<tr><td align=right><$font>Uw emailadres:</font></td>
<td><input type=text name="email" value="$in{'email'}" size=40></td></tr>
<tr><td align=right><$font>Onderwerp:</font></td>
<td><input type=text name="subject" value="$in{'subject'}" size=40></td></tr>
<tr><td valign=top align=right><$font>Boodschap:</font></td>
<td><textarea name="emailmessage" ROWS="4" COLS="40" WRAP="VIRTUAL" MAXLENGTH="255">$in{'emailmessage'}</textarea></td></tr>
</table><br>
<center>
<INPUT TYPE="SUBMIT" NAME="send_email" VALUE="Zend Email">
<INPUT TYPE="RESET" VALUE="Wis inhoud">
</table>
</form>
|;
# <-- end of page formatting -->
&html_footer;
print qq|</td></tr></table></body></html>|;
}
sub html_send_email_success {
#----------------------------------
my ($message) = $_[0];
&html_print_headers;
# <-- top of page formatting -->
print qq|
<html><head><title>$html_title: Email sturen</title></head>
<body bgcolor="#FFFFFF">
<center>
<table border=1 bgcolor="#D2FFD2" cellpadding=5 cellspacing=3 width=485 align=center valign=top>
<tr><td colspan=2 border=0 bgcolor="#006200">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Email sturen</b></td></tr>
<tr><td><p><center><$font_title><b>Email verzonden</b></font></center><br>
|;
# <-- text -->
print qq|<$font>De Email boodschap is verzonden aan $message.</font></table>|;
# <-- end of page formatting -->
&html_footer;
print qq|</td></tr></table></body></html>|;
}And from the script:
#-----------------------------------
unless ($in{'email'}) { $message = "You must fill in your email address<BR>"; }
unless ($in{'email'} =~ /.+\@.+\..+/) { $message = "Your email address is not in the correct format.<BR>"; }
unless ($in{'subject'}) { $message .= "You must fill in a subject for your message.<BR>"; }
unless ($in{'emailmessage'}) { $message .= "Your email message is empty.<BR>"; }
%rec = &get_record($in{$db_key});
if (!%rec) { $message .= "The email address you requested could not be found.<BR>"; }
if (!$rec{'Email'}) { $message .= "There is no email address on file for this person.<BR>" }
if ($message) {
chomp($message);
&html_send_email_form($message);
return;
}
open (MAIL, "$mailprog") | | &cgierr("unable to open mail program");
print MAIL "To: $rec{'Email'}\n";
print MAIL "From: $in{'email'}\n";
print MAIL "Subject: $in{'subject'}\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL $in{'emailmessage'};
close (MAIL);
&html_send_email_success($rec{'Naam'});
}just posting my sub 'get_record' from the script:
# --------------------------------------------------------
# Given an ID as input, get_record returns a hash of the
# requested record or undefined if not found.
my ($key, $found, $line, @data, $field, $restricted);
$key = $_[0];
$found = 0;
($restricted = 1) if ($auth_modify_own and !$per_admin);
if ($id_vk){$db_file_name = "/opt/guide/www.autorandstad.nl/cgi-bin/dbman/voorkeur.db";}
open (DB, "<$db_file_name") or &cgierr("error in get_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
$line = $_; chomp ($line);
@data = &split_decode($line);
next LINE if ($restricted and ($db_userid ne $data[$auth_user_field]));
if ($data[$db_key_pos] eq $key) {
$found = 1;
for ($i = 0; $i <= $#db_cols; $i++) { # Map the array columns to a hash.
$rec{$db_cols[$i]} = $data[$i];
}
last LINE;
}
}
close DB;
$found ?
(return %rec) :
(return undef);
}Hope that someone see whats wrong.
Thanks in advance.
---------
Mart.
[This message has been edited by mart (edited August 14, 1999).]
I can't load the '%rec = &get_record($in{$db_key})' as a default or registered user. Only with my own records, when I will sent an email, the values are loaded.
What can be wrong??? I will post all my codes. Sorry for the scrolling...
Code:
sub html_send_email_form { #--------------------------------------
my ($message) = $_[0];
&html_print_headers;
%rec = &get_record($in{$db_key});
if ($in{'Userid'}) {
$in{'Userid'} = $db_userid;
my ($status,@hits) = &query("view");
$in{'email'} = $hits[17];
$in{'name'} = $hits[22];
$in{'place'} = $hits[23];
$in{'phone'} = $hits[24];
$in{'emailmessage'} =
"Geachte $rec{'Naam'},
Kunt u met mij contact opnemen i.v.m. uw auto,
de $rec{'Merk'} $rec{'Type'}.
Alvast bedankt voor de moeite en tot ziens!!
Hoogachtend, $in{'name'}
$in{'phone'}
$in{'place'}
==============";
}
# <-- top of page formatting -->
print qq|
<html><head><title>$html_title: Email versturen</title></head>
<body bgcolor="#FFFFFF">
<center>
<table border=1 bgcolor="#D2FFD2" cellpadding=5 cellspacing=3 width=485 align=center valign=top>
<tr><td colspan=2 border=0 bgcolor="#006200">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Email versturen</b></td></tr>
<tr><td><p><center><$font_title><b>Email sturen</b></font></center><br>|;
# <-- introductory text -->
if ($message) { print qq|Los de fouten op:<br><font color="red"><$message|; }
print qq|<center>
<$font>Vul hier het Onderwerp in en de boodschap die verzonden moet worden aan <b>$rec{'Naam'}</b>.</font>
|;
# <-- email form -->
$in{'subject'} = "Re:$rec{'Merk'} $rec{'Type'}.";
print qq|
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="$db_key" value="$in{$db_key}">
<table>
<tr><td align=right><$font>Uw emailadres:</font></td>
<td><input type=text name="email" value="$in{'email'}" size=40></td></tr>
<tr><td align=right><$font>Onderwerp:</font></td>
<td><input type=text name="subject" value="$in{'subject'}" size=40></td></tr>
<tr><td valign=top align=right><$font>Boodschap:</font></td>
<td><textarea name="emailmessage" ROWS="4" COLS="40" WRAP="VIRTUAL" MAXLENGTH="255">$in{'emailmessage'}</textarea></td></tr>
</table><br>
<center>
<INPUT TYPE="SUBMIT" NAME="send_email" VALUE="Zend Email">
<INPUT TYPE="RESET" VALUE="Wis inhoud">
</table>
</form>
|;
# <-- end of page formatting -->
&html_footer;
print qq|</td></tr></table></body></html>|;
}
sub html_send_email_success {
#----------------------------------
my ($message) = $_[0];
&html_print_headers;
# <-- top of page formatting -->
print qq|
<html><head><title>$html_title: Email sturen</title></head>
<body bgcolor="#FFFFFF">
<center>
<table border=1 bgcolor="#D2FFD2" cellpadding=5 cellspacing=3 width=485 align=center valign=top>
<tr><td colspan=2 border=0 bgcolor="#006200">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Email sturen</b></td></tr>
<tr><td><p><center><$font_title><b>Email verzonden</b></font></center><br>
|;
# <-- text -->
print qq|<$font>De Email boodschap is verzonden aan $message.</font></table>|;
# <-- end of page formatting -->
&html_footer;
print qq|</td></tr></table></body></html>|;
}
Code:
sub send_email { #-----------------------------------
unless ($in{'email'}) { $message = "You must fill in your email address<BR>"; }
unless ($in{'email'} =~ /.+\@.+\..+/) { $message = "Your email address is not in the correct format.<BR>"; }
unless ($in{'subject'}) { $message .= "You must fill in a subject for your message.<BR>"; }
unless ($in{'emailmessage'}) { $message .= "Your email message is empty.<BR>"; }
%rec = &get_record($in{$db_key});
if (!%rec) { $message .= "The email address you requested could not be found.<BR>"; }
if (!$rec{'Email'}) { $message .= "There is no email address on file for this person.<BR>" }
if ($message) {
chomp($message);
&html_send_email_form($message);
return;
}
open (MAIL, "$mailprog") | | &cgierr("unable to open mail program");
print MAIL "To: $rec{'Email'}\n";
print MAIL "From: $in{'email'}\n";
print MAIL "Subject: $in{'subject'}\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL $in{'emailmessage'};
close (MAIL);
&html_send_email_success($rec{'Naam'});
}
Code:
sub get_record { # --------------------------------------------------------
# Given an ID as input, get_record returns a hash of the
# requested record or undefined if not found.
my ($key, $found, $line, @data, $field, $restricted);
$key = $_[0];
$found = 0;
($restricted = 1) if ($auth_modify_own and !$per_admin);
if ($id_vk){$db_file_name = "/opt/guide/www.autorandstad.nl/cgi-bin/dbman/voorkeur.db";}
open (DB, "<$db_file_name") or &cgierr("error in get_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
$line = $_; chomp ($line);
@data = &split_decode($line);
next LINE if ($restricted and ($db_userid ne $data[$auth_user_field]));
if ($data[$db_key_pos] eq $key) {
$found = 1;
for ($i = 0; $i <= $#db_cols; $i++) { # Map the array columns to a hash.
$rec{$db_cols[$i]} = $data[$i];
}
last LINE;
}
}
close DB;
$found ?
(return %rec) :
(return undef);
}
Thanks in advance.
---------
Mart.
[This message has been edited by mart (edited August 14, 1999).]