This is the code that leads up to the search function. Can anyone see what is wrong?!
__________________________________________________________
#!/usr/bin/perl
## modify.cgi: To modify profiles
$com = "/usr/bin/grep";
$idx = "agents.idx";
## Parse the input
if ($ENV{'REQUEST_METHOD'} eq "POST")
{
read(STDIN,$realquery,$ENV{'CONTENT_LENGTH'});
@F = split(/\&/,$realquery);
foreach $f (@F)
{
($n, $v) = split(/=/,$f);
$v =~ s#\+# #g;
$v =~ s#%([0-9a-fA-F][0-9a-fA-F])#sprintf("%c",hex($1))#eg;
$fields{$n} = $v;
}
}
else
{
print <<EOM;
Content-type: text/plain
Invalid REQUEST_METHOD served.
EOM
exit;
}
## Convert & validate variables
$opr=$fields{'opr'}; $idx=$fields{'idx'};;
$firstname=$fields{'firstname'}; $lastname=$fields{'lastname'};
$position=$fields{'position'}; $extension=$fields{'extension'};
$email=$fields{'email'}; $notes=$fields{'notes'};
$image1=$fields{'image1'};$image2=$fields{'image2'};
$image3=$fields{'image3'};$ename=$fields{'ename'};
$reupdate1=$fields{'reupdate1'};$reupdate2=$fields{'reupdate2'};
$reupdate3=$fields{'reupdate3'};$reupdate4=$fields{'reupdate4'};
if ($opr eq "locate")
{
if ($ename eq '')
{
print <<EOM;
Content-type: text/html
<HEAD>
<TITLE>Incomplete Request</TITLE>
</HEAD>
<BODY background="bg.gif" topmargin=0 leftmargin=0
onLoad="window.defaultStatus=''" link="#273C82" alink="#273C82" vlink="#273C82">
<center><img src="Profiles.gif" width="742" height="122"></center><br>
<center><table width=500 cellpadding=5>
<tr><td align=center><font size=+1 face=arial><b>Incomplete Request</b></font>
<p><font size=2 face=arial>Please go back and enter a valid E-Name.</b>
<p>Thanks!</font></td></tr>
</table></center>
</HTML>
EOM
exit;
}
## Grab item from index
$res = `exec '$com' -i "$ename¦" $idx`; chop $res;
$new = `exec '$com' -i -v "$res¦" $idx`; chop $new;
__________________________________________________________
I can't find what is wrong.. it never finds the $ename field from the database!
>> $v =~ s#\+# #g;
>> $v =~ s#%([0-9a-fA-F][0-9a-fA-F])#sprintf("%c",hex($1))#eg;
First, it seems a pretty bad idea to use these # in stead of these / as the former are used for commenting out lines.
Second, when printing out your html page, remember to send the header like this:
print "Content-type: text/html\n\n";
- the two "\n" are vey important, as exactly two are needed to end the header.
/claus