Hi all,
I must admit - I don't know where to post this!

I would like to add a page where users can submit favorite songs. I was thinking of using a guestbook but what I would really like is to have a very simple form with 4 fields and the entries would populate on the webpage.

Question - should I create a simple form or just use a guestbook (and if I should use a guestbook, any recommendations would help).

I have never created a form or used a guestbook. I have found tutorials for forms, but I do not want the forms submitted to me via email. Is there a tutorial somewhere out there?

I am using my wedding site to teach myself xhtm and css and any other skills I can.

Sorry for the long post.

- Josh

Dani AI

Generated

As noted, submitted data has to be stored somewhere. Given has DreamHost/MySQL access, the simplest, lowest-maintenance route is a small database + a tiny server handler (PHP is a good beginner choice, as suggested). Hand-coding this will teach fundamentals you can reuse elsewhere.

Create a compact table (your form can present 4 fields; the table can add id and created_at for tracking):

CREATE TABLE songs (
  id INT AUTO_INCREMENT PRIMARY KEY,
  title VARCHAR(255) NOT NULL,
  artist VARCHAR(255) NOT NULL,
  url VARCHAR(255),
  submitter VARCHAR(100),
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB;

A minimal accessible HTML form (four visible fields) — POST to submit.php:

<form method="post" action="submit.php">
  <label>Song title: <input name="title" type="text" required maxlength="255"></label>
  <label>Artist: <input name="artist" type="text" required maxlength="255"></label>
  <label>URL: <input name="url" type="url" maxlength="255"></label>
  <label>Your name: <input name="submitter" type="text" maxlength="100"></label>
  <button type="submit">Add</button>
</form>

Handle submissions with PDO and prepared statements, validate server-side (lengths, filter_var(..., FILTER_VALIDATE_URL)), and always escape on output with htmlspecialchars. Store raw text but never trust input; escaping on output prevents XSS.

Display entries ordered by created_at and escape fields when rendering. Add small UX touches: inline validation, clear success message, and pagination if the list grows.

Quick troubleshooting and cautions:

  • DreamHost DB host may not be localhost — check the panel.
  • Enable PDO and exceptions while developing; check credentials and DB name.
  • Rate-limit or moderate submissions to prevent spam (CAPTCHA or manual approval).
  • In production, log errors but disable display_errors.

Good quick references: MDN’s forms guide (MDN Forms) and DreamHost’s MySQL help (DreamHost MySQL help).

Recommended Answers

All 6 Replies

Well, if you want to display the data, it has to go somewhere.

1) Email to you, you edit the page.
2) Save to file, page loads files.
3) save to DataBase, page loads DB.

I think those are your three main options.

So, 1 is out, leaving 2/3.
You could use a "scripting language" for this, and there are examples out there of how to do it...

You could have a script that everytime the form is filled in, it saves the data into a new file, and then the page loads up, reads all the files and inputs the values ito the page.

Or you could use a DB, then you can either use a real "DB Engine" such as mySQL, or a "Flat File DB" usig JS/PHP etc. (saves thestuff as entries in a file, then reads each entry as a record).


It does depend on the Host, though almsot all offer some form of DB (usually MySQL) and some scripting/language support (php/asp etc.).

There are plenty of little DB scripts out there... look to Hot Scripts etc. You will find examples, and even little tutorials for it.

Thanks autocrat. I will check hotscripts. I am using dreamhost, so I have access to MySql. I started working on a basic ruby tutorial, but that will take me a while to learn as I have no programming experience.

- Josh

You can look self-paced the PHP tutorial from w3schools (PHP is the most easier language) and then you can look feedback and contact form tutorials from Google to get a general idea.
Start using Dreamweaver 8, you can do DB queries easily and another stuff automatically. If you want to set programming as your primarly goal start learning PHP and OOP, use the ezsql class to create DB queries for example.
PHP are very documented, you could find more tutorials than another language.

Nothing personal, but I would state not to follow ... martin5211 ... adviceo n DreamWeaver - I've found a huge number of people don't actually understand what they do because they use software that does most of the work.

If you are to learn, then YOU learn.
Hell, I still do a fair bit of coding in things like Notepad if I don't have a machine with phpDesigner on it!

By al means use DreamWeaver - but make sure you understand what you are doing :)

Personally, I don't like very much Dreamweaver 8 because now I have my own style, but I've to admit that in the first two weeks I started to build a social networking site, you don't have to worry very much, and you can focus to learn the most basics things: array manipulation, iterate arrays to display content, conditions to show, hide sections of the website and send parameters by url in forms.

PHP.net is a great resource, almost all examples are very easy, you can copy&paste and see the results, then modify it and apply your idea. For example, the foreach example to read an array and the subsequent examples to deal with multidimensional arrays (arrays like excel spreadsheets). The foundations of PHP are very basic, you have to learn not to see all like very complex.

phpDesigner is more cheaper and lighter than Dreamweaver, it have a great potential but have confussing behaviors: automated hiding of php or html code, and the instantaneous bug reporter, both very annoying for beginners.

? phpDesigner has a bug reporter?

Must be in one of the new versions... I'm still on 2005's (I've looked at the newer ones and can't stad them).

Still, in a way I guess it isn't the tools that makes people bad, it's the people themselves.
So I guess it doesn't matter what you use - it's jsut my pet peeve of monkeys and dreamweaver ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.