Click to See Complete Forum and Search --> : Help on my script please


Sephiroth32
12-13-2002, 04:32 PM
well after making my guestbook script ZAPbook I decided to try a new sort of script.

It is an affiliation request/hosting request program wherre it makes a table of all the requests made by users so you can keep track of them.

Unfortunately I am not an expert at CGI so I cannot figure out how to deal with some key features I would like to include.

I would like users to be able to check a checkbox that says "accept" or "decline" and it would move the entries to different tables depending on the box that is checked. Once the entries are in there database files I have no problem putting them in the tables but I cannot figure out how to move certain lines from a databse to another databse. I also do not see how you can delete/move only certain lines from the databse/to another databse just by checking a box.

http://www.unitedff.com/cgi-bin/hostinga.cgi is the main listing.

If you need my code I will post it.

Please help! Thanks in advance

jeffmott
12-14-2002, 04:51 AM
Unfortunately I am not an expert at CGI

CGI is a network protocol, so I'll assume that it is Perl you're working with.

but I cannot figure out how to move certain lines from a databse to another databse

What kind of database are you using?

I also do not see how you can delete/move only certain lines from the databse/to another databse just by checking a box

Checking the box won't do the move operation.This will only provide information to the script of where to move the db entry, if at all.

Sephiroth32
12-14-2002, 10:30 AM
no I know that........(about the checkbox i'm not computer illiterate :p)

anyway the kind of databse I am using is a text file that stores the info like this

thing|thing|thing|thing

jeffmott
12-14-2002, 10:52 AM
thing|thing|thing|thing

Well, generally one of these things is an ID number. Here's an example db file and how you can get a specific entry from it.

-- file.db --

id|1|name|Steve|phone|5550001
id|2|name|Josh|phone|5550002
id|3|name|Lisa|phone|5550003

-- Perl script --

use CGI 'param';
use Fcntl ':flock';

my $id = param('id'); # the id your looking for

open(DB, 'file.db') or die $!;
flock DB, LOCK_SH;
while (<DB>) {
&nbsp; chomp $_;
&nbsp; my %entry = split(/\|/, $_);
&nbsp; if ($entry{id} == $id) {
&nbsp; &nbsp; # found the entry, do stuff with it
&nbsp; &nbsp; last;
&nbsp; }
}
close DB;

If your db file is large and all the id numbers are sorted then you could alternately use a binary search to speed up the process.

jeffmott
12-14-2002, 10:55 AM
And just as a separate comment, I'd recommend using other characters than | or \n, or anything else the user might input. Depending on how you handle it, it will either 1) allow the user to play with your db file, or 2) frustrate the user when their message doesn't show up the way they typed it.

Sephiroth32
12-14-2002, 05:26 PM
thanks to both of you!

I really appriciate it