Results 1 to 8 of 8

Thread: CGI guestbook

  1. #1
    Join Date
    Dec 2002

    CGI guestbook

    Ok I would like to create a guestbook on my website. I want to use CGI, Do i need to make a database for the submitted text to be dislplayed? If so ... How? I can only use PHP or SQL for database

  2. #2
    Join Date
    Nov 2002
    NY, USA
    PHP and SQL are both languages, not databases. You'll have to check with your server for what database they do offer. Otherwise, you'll have to look into implementing your own.

  3. #3
    Join Date
    Dec 2002
    database is mySQL Database

  4. #4
    Join Date
    Nov 2002
    NY, USA

  5. #5
    Join Date
    Dec 2002
    If you are writing your own guestbook script, you may find it easier to use a flat textfile database. That is, if you are new to CGI. Yes, MySQL is a million times more powerful than your ordinary textfile database, but it doesn't require the 'difficult' "language" for querrying a MySQL database.

  6. #6
    Join Date
    Dec 2002
    i would love to be able to write a textfile database.. how do i do that?

  7. #7
    Join Date
    Dec 2002
    open (FILEHANDLE, "path/to/file/database.dat");
    print FILEHANDLE "data|you|want|saved";

    This is the basic way to write to a textfile database with PERL. FILEHANDLE should be changed to what you want. Could be DATA, FILE, whatever you want. But each different database that you open should have a different filehandle. The path in the quotes and the filename tells the script the location of the text file you want to write to.

    This file can be .txt, .dat, or for my own scripts I often use .cms (a file extension I created from my initials). As long as the file is capable of being written to, your script can write to it.

    The second line tells the script what to write to the database. If you are familiar with databases, you have the database delimited by something. This will tell the script what pieces of info in the database are. These are just like field columns in MySQL (more or less). I like to use pipes "|" to delimit my fields. But you can use pretty much anything, but stay away from common strokes such as commas because if anyone types a comma in whatever their input is, you will have a messed up database. But a pipe is rarely used by people filling out forms whos info is saved to a database so they tend to be safe. Some people like double colons "::" If you have a database with users' usernames, passwords, and E-mail addresses and you want to save a new user's info to the database, you could have:

    open (USERS, ">cgi-bin/profiler/users/userdatabase.dat");
    print USERS "$username|$password|$email\n";

    Of course you will have to set the scalars used in that sample to something which will probably be done with a sign up form (registration form where the users input the username and password they want and their E-mail address).

    The > in the first line tells the script to save over the information already in the database. If you always want new info to be saved over the old and do not want the old info in there, just have the single > and the new info will replace the old.

    But in the example above, you would obviously want to save all users' info to the database and not copy over the previous users info. So you should have >> instead of just one. This will tell the script to take the new user's info and append it to the bottom of the database. Which will keep the old information intact.

    You can create a textfile on your harddrive called userdatabase.dat and upload it to your server and the script will automatically use it as the database. But if you run the script without uploading the database, most servers will automatically create the file.

    This is just the tip of the iceberg. You will want to learn about file locking. if you are creating a database that a lot of people will be saving information to at the same time, it keeps the database's attention as it prints one person's info and then saves another person's or else you could have two peoples' information mixing into one line.

    You will also need to learn the proper ways to draw the information from the database for use in your scripts.

    Good luck.

  8. #8
    Join Date
    Dec 2002
    Because you said (I think) that you know PHP, I can offer some suggestions for getting a similar result using PHP and MySQL. SQL can be somewhat hard to learn, but PHP is a good deal easier to use than PERL, from what I've foundm especially for a guestbook.

    If you don't know much of MySQL, it might be a good idea to get a free script called phpMyAdmin, which lets you edit your database (for making it, setting up tables/columns, etc.) without (or with) using the SQL language. (http://www.phpmyadmin.net/)

    However, you will need to learn SQL for accessing the data with PHP. These sites have some pretty good SQL tutorials:


    After you learn SQL, it's just a matter of implementing it with PHP, and you can learn that by clicking on jeffmott's link, finding another online tutorial, or reading a PHP book that includes MySQL functions (many do).


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.29215 seconds
  • Memory Usage 2,907KB
  • Queries Executed 13 (?)
More Information
Template Usage (32):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (8)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • bbcode_parse_start
  • postbit_imicons
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates