Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you set the link up

Status
Not open for further replies.

AmandaBurke

Programmer
Aug 24, 2000
6
CA
Hi,

I have a text file that is saving my link in it. How do I tell the link, what to link to?? Because the link in the text file is the id field of the database and what I want it to do is to when the link is clicked to call up the edit page and display the information for the line of database where the link is.

example

(Edit)1002 08/06/00 Amanda Whatever Why Machine File

Edit is the link and it knows that it is showing 1002, but how do I get this to call the edit screen??? [sig][/sig]
 
#/perl

....a bunch of house keeping stuff and then....

Code:
@fields = split(/\t/,$line);

# now we need to catch the contents of the parens....
$tmp = $fields[0];
$tmp =~ /\((.*?)\)/;
$dowhat = $1; # $dowhat now contains 'Edit'
$id = $'; # now $id contains '1002'
# build a link that looks like,
# <a ref=[URL unfurl="true"]http://yourserver.com/cgi-bin/code.cgi?dowhat=Edit&who=Amanda&[/URL]
# file=File>Some descriptive text</a>
$link = '<a href=&quot;' . &quot;$dowhat.&quot;.'&who='.&quot;$fields[2]&quot;.'&file='.&quot;$fields[6]&quot;. '&quot;>';
print $link;
[sig]<p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo[/sig]
 
I'm sending you my code and maybe you can help to fix it. If you do not have time, I understand I'm going to keep trying to get it to work. Thanks so much for all of your help, I would not even be this far with out it.
#!/usr/bin/perl -w

# Constants for flock
#
$LOCK_SH = 1;
$LOCK_EX = 2;
$LOCK_NB = 4;
$LOCK_UN = 8;
#
# The database file name
# Always has to have FULL UNIX path in order to work.
# Just in case you're adapting this for another purpose.
#
$db_file = &quot;/usr/local/apache/share/htdocs/helplog/helplog.dat&quot;;


if ($ENV{'REQUEST_METHOD'} eq 'POST') {

# Get the input

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs

@pairs = split(/&/, $buffer);

# Load the FORM variables

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;

$FORM{$name} = $value;
}

# Edit line item.
&db_write;

# Thank the user and acknowledge
# the feedback generating a new page. (and then exit)
#
&thank_you;
}

&sub_error;

sub sub_error {
# Format an error message for the user

print &quot;Content-type: text/html\n\n&quot;;
print &quot;<HTML>\n&quot;;
print &quot;<HEAD>\n&quot;;
print &quot;<TITLE>Request Form Error</TITLE>\n&quot;;
print &quot;</HEAD>\n&quot;;
print &quot;<BODY>\n&quot;;
print &quot;<H1>Request Form Error</H1>\n&quot;;
print &quot;<HR>\n&quot;;
print &quot;<P>\n&quot;;
print &quot;Form input was not proccessed. Please mail your &quot;;
print &quot;remarks to $FORM{submitaddress}\n&quot;;
print &quot;</BODY>\n&quot;;
print &quot;</HTML>\n&quot;;
}

sub thank_you {

# Generate the &quot;thank you&quot; page for after they have submitted
# their information.
# The information comes from the variable created in the
# database subroutine.
print &quot;Content-type: text/html\n\n&quot;;
print &quot;<HTML>\n&quot;;
print &quot;<HEAD>\n&quot;;
print &quot;<TITLE>Thank You!</TITLE>\n&quot;;
print &quot;</HEAD>\n&quot;;
print &quot;<BODY BGCOLOR=#FFFFFF TEXT=#000000>\n&quot;;
print &quot;<H1>Thank You!</H1>\n&quot;;
print &quot;\n&quot;;
print &quot;<P>\n&quot;;
print &quot;<H3>Your log information has been updated.&quot;;
print &quot;<P>\n&quot;;
print &quot;Your log entry change is as follows:\n<table width=\&quot;60%\&quot;><tr><td><pre>$new</pre></td></tr></table>$
print &quot;<P>\n&quot;;
print &quot;If this information is incorrect please e-mail your corrections to: \n&quot;;
print &quot;<A HREF='mailto:maiac\@gilmore.ca'>maiac\@gilmore.ca</A>.\n&quot;;
print &quot;<P>\n&quot;;
print &quot;</BODY>\n&quot;;
print &quot;</HTML>\n&quot;;
exit;
}

sub db_write {
# open the database file in read mode.
# don't forget to close it after you are done
$count = 1000;
open(DATABASE, &quot;<$db_file&quot;);
$count++ while<DATABASE>;
close(DATABASE);

# Open database for append and lock it to ensure exclusive access.
open(DATABASE, &quot;>>$db_file&quot;);
flock(DATABASE, $LOCK_EX);

# Create some variables for the information coming in

$old=$FORM{idnum};

# Build new record.
$new .= &quot;$count\t$old\t$FORM{date}\t$FORM{user}\t$FORM{what}\t&quot;;
$new .= &quot;$FORM{why}\t$FORM{machine}\t&quot;;
$new .= &quot;$FORM{filemodified}\t$FORM{status}\t\n&quot;;

# Pipe everything except the line in question into an array.
# @stuff = <DATABASE>;
# @stuff = splice(@stuff, $old, \n);

# Dump the now changed information back into the file
# @stuff =(DATABASE, $db_file);

# Seek the line number in question in the original database
# seek(DATABASE, $idnum, 1);

# Add the new information to the current database in the same
# location as the previous data.
print DATABASE $new;

# Unlock the file for others then close it
# to finish off.
# Exit takes place in the thank_you subroutine.
flock(DATABASE, $LOCK_UN);
close(DATABASE);
}



Searchlog.
#!/usr/bin/perl -w
if ($ENV {'REQUEST_METHOD'} eq 'POST') {
# Get the information to search for:
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split name/value pairs
#$pairs = split(/&/, $buffer);
# Load the variables from the form
foreach $pair (split(/&/, $buffer)) {
# Split the values from the form
($key, $value) = split(/=/,$pair);
# Remove &quot;+&quot; signs
$key =~ tr/+/ /;
$value =~ tr/+/ /;
# Allows for either Upper or lower case
$key=~s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$value=~s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$parameters{$key} = $value;
}

# Open the file that will be used to display the information
system(&quot;: > /usr/local/apache/share/htdocs/helplog/temp.dat&quot;);
open(TEMP, &quot;>>/usr/local/apache/share/htdocs/helplog/temp.dat&quot;);
# Open the helplog file that contains the entries
open(FILE, &quot;/usr/local/apache/share/htdocs/helplog/helplog.dat&quot;);
while($line = <FILE>)
{

($num,$groupid,$date,$user,$what,$why,$machine,$filemodified,$status) =$
if ($num eq $parameters{'num'})
{
@fields = split(/\t/, $line);
$link = '<A HREF=&quot;'//help/itdept/editlog.cgi?num=.$fields[0].'&quot;>Edit</a$
print TEMP $link;
print TEMP $line;
}

if ($groupid eq $parameters{'groupid'})
{
@fields = split(/\t/, $line);
$link = '<A HREF=&quot;' .$fields[0]. '&quot;>Edit</a>';
print TEMP $link;
print TEMP $line;
}
elsif ($date eq $parameters{'date'})
{
@fields = split(/\t/, $line);
$link = '<A HREF=&quot;' .$fields[0]. '&quot;>Edit</a>';
print TEMP $link;

print TEMP $line;
}
elsif ($user eq $parameters{'user'})
{
@fields = split(/\t/, $line);
$link = '<A HREF=&quot;' .$fields[0]. '&quot;>Edit</a>';
print TEMP $link;
print TEMP $line;
}
elsif ($what eq $parameters{'what'})

{

@fields = split(/\t/, $line);
$link = '<A HREF=&quot;' .$fields[0]. '&quot;>Edit</a>';
print TEMP $link;
print TEMP $line;
}
elsif ($why eq $parameters{'why'})
{
@fields = split(/\t/, $line);
$link = '<A HREF=&quot;' .$fields[0]. '&quot;>Edit</a>';
print TEMP $link;
print TEMP $line;
}
elsif ($machine eq $parameters{'machine'})
{
@fields = split(/\t/, $line);
$link = '<A HREF=&quot;' .$fields[6]. '&quot;>Edit</a>';
print TEMP $link;
print TEMP $line;

}
elsif ($filemodified eq $parameters{'filemodified'})
{
@fields = split(/\t/, $line);
$link = '<A HREF=&quot;' .$fields[0]. '&quot;>Edit</a>';
print TEMP $link;
print TEMP $line;
}
elsif ($status eq $parameters{'status'})
{

@fields = split(/\t/, $line);
$link = '<A HREF=&quot;' .$fields[0]. '&quot;>Edit</a>';
print TEMP $link;
print TEMP $line;
}
elsif ($status eq $parameters{'status'})
{
@fields = split(/\t/, $line);
$link = '<A HREF=&quot;' .$fields[0]. '&quot;>Edit</a>';
print TEMP $link;
print TEMP $line;
}

}

close(TEMP);
close(FILE);

# Generate the page
&thank_you;

# Error sub routine just in case script blows up.
&error;

sub thank_you
{
open (TEMP, &quot;/usr/local/apache/share/htdocs/helplog/temp.dat&quot;);
@line = <TEMP>;
# Generate the &quot;info&quot; page that spews all the information requested
# in the search.
print &quot;<Content-type: text/html\n\n&quot;;
print &quot;<HTML>\n&quot;;
print &quot;<HEAD>\n&quot;;
print &quot;<TITLE>Results of your search</TITLE>\n&quot;;
print &quot;</HEAD>\n&quot;;
print &quot;<BODY>&quot;;
print &quot;<H1>Results</H1>\n&quot;;
print &quot;\n&quot;;
print &quot;<P>\n&quot;;
print &quot;Your results from the search are as follows:\n<TABLE><TR><TD><PR$
print &quot;<P>\n\n&quot;;
print &quot;<BR>&quot;;
print &quot;<A HREF=' the Database</A>.$
print &quot;<BR><BR><BR>&quot;;
print &quot;If you encountered problems with this search, or have questions $
print &quot;<A HREF='mailto:maiac\@gilmore.ca'>Webmaster</A>.\n&quot;;
print &quot;<P>\n&quot;;
print &quot;</BODY>\n&quot;;
print &quot;</HTML>\n&quot;;
exit;
close (TEMP);
}

sub error
{
print &quot;Content-type: text/html\n\n&quot;;
print &quot;<HTML>\n&quot;;
print &quot;<HEAD>\n&quot;;
print &quot;<TITLE>Request Form Error</TITLE>\n&quot;;
print &quot;</HEAD>\n&quot;;
print &quot;<BODY>\n&quot;;
print &quot;<H1>Request Form Error</H1>\n&quot;;
print &quot;<HR>\n&quot;;
print &quot;<P>\n&quot;;
print &quot;Form input was not processed. Please try again.&quot;;
print &quot;</BODY>\n&quot;;
print &quot;</HTML>\n&quot;;


}
}




[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top