CSVEdit - Edit and delete information in your database

Administrator tool to manage your CSV database online without FTP. Add and edit records in your database, add or remove fields. The advanced version will split records over a number of pages and allow you to and search records. (CGI/Perl Unix)

» Overview of the script
» Set-up the script
» Create your database
» Create your HTML template
» Running the script

Overview of the script

CSVedit:
Using a link or typing the URL in your browser, the script will open all your CSV database allowing you to edit and delete information.

CSVedit Xtra:
Using a link or typing the URL in your browser, enter your username and password, the script will open all your CSV database and split the data over many pages, allowing you to search, edit, delete and add records.

Current versions:
Basic 28/Oct/2006
XTra 17/Aug/2006

Files you will need:
CSVedit script (download from this website)
Database (instructions on this page)
Template (download from this website)

Things you have to do:
Follow the instructions below
Download the CSVedit script and make a few changes
Create a database (or let CSVwrite do it!)
Customise your template
Upload the script

Minimum Requirements:
Your own website with FTP access
Permission to run CGI scripts on your server
UNIX web hosting with Perl 5.006001 or greater
Sendmail or access to SMTP (Xtra Version)

Features CSVedit Xtra
For commercial and private use YES YES
Can be used on as many websites as I build YES YES
No adverts or links in the script YES YES
Instant download YES YES
Edit records in the database YES YES
Delete records in the database YES YES
Manage line breaks into HTML or spaces YES YES
Password protection - YES
Add a new record to the database YES YES
Search all the database or fields in the database - YES
Advanced page selector - YES
Split the results over many pages - YES
Choose the number of results per page - YES
Option to change the delimiter - YES
Option to change the character replacing delimiter - YES
Option to add an ID to a new record YES YES
Option to change the textbox for scrolling textbox - YES
Choose fields that you do not wish to display - YES
Choose fields that you do not wish to edit - YES
Option to allow or block HTML code  - YES
Add a new field to the database YES YES
Delete fields from the database YES YES
Customize the look using a template YES YES
Use the same template as CSVread & CSVsearch YES YES
Multiple database editing from the same script - YES
File upload (not possible on all web servers) - YES
File upload optional - YES
Reverse the order in which the records are shown - YES
Filter to block 'bad' words - YES
Use HTML includes in the template - YES

Back to Top


CSVedit

Check your path to perl
#!/usr/bin/perl

Name of this script, or FULL URL (Not Path).
my $prog_name = "csvedit.pl";

Change the PATH of your database.
If it is in the same directory as the script this should be okay
my $base_file = "database.txt";

Change the PATH of your template.
If it is in the same directory as the script this should be okay.
my $template = "edit-template.htm";

Error message if no data found
my $no_match = "Sorry, no results found!";

If you are using scrolling text boxes the script will need to remove any line breaks. This is then replaced with the HTML code for a line break, or you may wish to use a space.
my $line_break = '<br>';

Width of the table data is displayed in
my $table_width = 490;

Size of the text box for editing
my $text_box = 50;

You can add extra field to the database, to disable this feature use '0'
(this feature is not activated in the online demo)
my $add_fields = 1;

You can delete fields from the database, to disable this feature use '0'
(this feature is not activated in the online demo)
my $delete_fields = 1;

Advanced settings Auto ID:

If you would like CSVwrite Xtra to automatically write an ID number for each record then change $ID_autoincrement = 0 to 1
my $ID_autoincrement = 0;

Name the field you would like the script to write the ID number to.
my $ID_autoincrement_name = "ID";

Upload and CHMOD 755, or 777 if not public.

CSVedit Xtra

Check your path to perl
#!/usr/bin/perl

Name of this script, or local URL (Not Path).
my $prog_name = "csvedit.pl";

Change the PATH of your database.
If it is in the same directory as the script this should be okay
my $base_file = 'database.txt';

Change the PATH of your template.
If it is in the same directory as the script this should be okay.
my $template = "edit-template.htm";

Number of records per page
my $records_per_page = 5;

Text for 'previous' button
my $textPrevious = "<<";

Tex for 'next' button
my $textNext = ">>";

Number of pages in the range at any time
my $pageSelectorRange = 10;

Error message if no data found
my $no_match = "Sorry, no results found!";

If you are using scrolling text boxes the script will need to remove any line breaks. This is then replaced with the HTML code for a line break, or you may wish to use a space.
my $line_break = '<br>';

Normally you will see the first record in the database being listed first.  If you want to see the latest database additions listed first, then set this option to 1.
my $reverse_order = 0;

Advanced settings Multi-Database Mode:

You can use CSVedit Xtra to edit more than one database. To get this mode working simply change $multyOn = 0; to $multyOn = 1;
my $multyOn = 0;

This is the field name for the drop-down-menu.  Use a name without spaces !
my $DBname = "database";

Next add the path and name to each database, note the last database has not got the , at the end. You can add as many as you like.
my %DB = (
"default" => $base_file,
"database2" => "database2.txt",
"database3" => "database3.txt",
"database4" => "database4.txt",
"database5" => "database5.txt",
"database6" => "database6.txt"
);


Advanced settings password protection:

Enter a username and password or leave blank if you don't want to use this option
my $Username = 'username';   (or: my $Username = '';)
my $Password = 'password';   (or: my $Password = '';)


Advanced settings new records:

If you wish to write the users IP address, Browser information and the Date to your database when using CSVedit Xtra to write a new record, you can by changing the '0' to '1'.

The first time CSVwrite is used it will create the database and add the fields. If you are creating your own database you will need to add the fields. |REMOTE_ADDR|HTTP_USER_AGENT|DATE

my $REMOTE_ADDR = 0;
my $HTTP_USER_AGENT = 0;
my $DATE = 0;


Advanced settings Auto ID:

If you would like CSVwrite Xtra to automatically write an ID number for each record then change $ID_autoincrement = 0 to 1
my $ID_autoincrement = 0;

Name the field you would like the script to write the ID number to.
my $ID_autoincrement_name = "ID";

Advanced settings character separator:

If you wish to use a different delimiter in the database to the pipe you can change it. However the pipe is the standard for web database scripts.
my $separator = '|'; 

If you wish to change the character the script used when a user inputs data with the delimiter. In this example we change the pipe for the letter I.
my $change = "I";

Advanced settings general:

You can select fields that you do not wish the script to display in the edit window, and fields that you wish to show, but not edit.
Input the field names as below, or leave blank. ();
my @no_show_fields = ("textbox","radiobutton");
my @no_edit_fields = ("textbox","radiobutton");


You can add extra field to the database, to disable this feature use '0'
(this feature is not activated in the online demo)
my $add_fields = 1;

You can delete fields from the database, to disable this feature use '0'
(this feature is not activated in the online demo)
my $delete_fields = 1;

To stop users posting HTML set this to 1, or 0 to allow HTML
my $kill_html_tags = 1;

You can select fields to have a large scrolling text box rather than a standard text box. Input the field names as below, or leave blank. ();
my @textareas = ("textbox","radiobutton");

The width of the table used to display the information.
my $table_width = 490;

The size of the scrolling text box for editing
my $rows = 4;
my $cols = 40;


Size of the text box for editing
my $text_box = 50;

Advanced Settings file upload

Most web hosting will block this feature for security reasons. Check with your host that you can use file upload from a form before using this feature.

Switch the file upload option off 0 /on 1
my $file_upload = 0;

If set to 1, the file upload fields become optional so they can be left blank without generating an error.
my $file_upload_optional = 0;

If you make the file upload optional, the script will assume a default file which you can manually upload to the file directory via FTP once when installing the script.  This would allow you to use a 1x1 pixels transparant image as default file.  When file uploading is optional and $rename_file is off, uploading an image with the default name is forbidden.
my $default_file = 'none.jpg';

The fields in your database that will have files to upload
my @file_upload_fields = ("fieldname","fieldname");

If you want the script to re-name the file. Strongly recommended security feature.
my $rename_file = 1;

The maximum size of file allowed.
my $error_max_size = 100000;

Types of files allowed. Do not allow .exe files on your server, don't leave this blank.
my @required_file_types = ("txt", "jpg", "jpeg", "tif", "gif");

Errors for wrong file type and files too large
my $error_max_size = "Your file is too big!";
my $error_file_type = "File type is not valid!";


The PATH not URL to the folder to take the files. Your host may block all or some folders from taking files. Note no final trailing slash / in the PATH.
my $file_dir = "/home/path/to/your/file/folder";

The URL not PATH to the folder to take the files. Your host may block all or some folders from taking files. Note no final trailing slash / in the URL.
my $fileURL = "http://www.your-url.co.uk/files";

Advanced Settings - Bad Words Filter

If you want to prevent visitors from using certain words, you should enable this option by setting it to 1:
my $use_filter = 0;

Then specify the PATH to a file in which you typed the 'forbidden' words (one at each line):
my $badwordsfile = 'badwords.txt';

If a bad word is found, it will be replaced by:
my $censored = '***';

Advanced Settings Include Pages

It is now possible to use HTML includes from the template.  Once you configured this, the script will replace each occurence of [[includex]] by the corresponding HTML page/file.
my $use_includes = 0;

If you want the script to cast an error when one of the templates could not be loaded, then set this value to 1:
my $error_on_missing = 0;

You can start defining which includes the script can use:
my %INCL=();
$INCL{'include1'} = "main-menu.htm";
$INCL{'include2'} = "main-menu.htm";
$INCL{'include3'} = "main-menu.htm";
$INCL{'include4'} = "main-menu.htm";
$INCL{'include5'} = "main-menu.htm";


Upload and CHMOD 755, or 777 if not public.

Back to Top


Create your database

You can create your database using notepad, but you don't need to!

The first time you run CSVwrite it will create the database for you, make sure you put some data in each field when you first run your form.

With the script you will get a sample database, you can edit this by adding new fields and records using CSVedit.

If you do create your own, don't use any special characters or spaces in the field names. Keep them short as your browser can only send a limited number of characters to the database at any one time. Ensure they match your form fields exactly. The size limitations of your database are determined by your web hosting and the server specifications.

Example database:
The first line is the heading and the rest the data. You can have as many field names as you like in the database.

Your database should be less than 1000 records and under 1MB run smoothly on most shared web servers. Save your database as a plain text file database.txt See the FAQ page for excel questions.

IMPORTANT: Please do not use field names in your database used in the script or template. The following are used by the scripts and can not be used as field names name, method, action, page, record, header, random, display, search, order_by, order, mode & headlines.

Upload and CHMOD 755, or 777 if not public.

Back to Top


Create your HTML template 

This will display the results in the way you wish to see them. Using any HTML web style you like. The script will display the HTML code from your template and display the database in a table for editing inside your <template> brackets </template>

So, you can use the same template for CSVread CSVsearch and CSVedit without making any changes. However, should you wish to use a separate template then one is included in the download with the script and the code is below.

The table and font is controlled by a <style sheet> at the top of the HTML code. See the code below and the sample in the download.

Example code:



The script will read and display the code from your template. You can not include any SSI (Server side includes) in the template. This is not possible with CGI Perl scripts.

If you have $use_includes set to 1, you will be able to include tags like [[include1]], [[include2]] to have the script copy and paste the HTML of the corresponding file into your template.  This system helps you replace SSI commands.

Back to Top


Running the script

/cgi-bin/csvedit.pl
Simply type the URL of your script in any web browser. When using this administration tool do not use the refresh button on your browser, after posting data as this will request the browser to post the data again.

Back to Top

 
 

home | rate the scripts | community support forum | © www.ezscripting.com