Home > Articles > Data > MySQL

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

A Sample Form


To try out a CGI program that uses MySQL, you first want a sample HTML form.

Here's one; save it on your Web server with an .html extension:



Figure 1Figure 1 Here's a sample form that calls a CGI script.


<html><head>
<title>CGI + MySQL + C++ Demo!</title></head> <body> <form method="post" action="http://localhost/cgi-bin/cgidemo1.exe"> What name would you like to search for?<br> <input type="text" name="name" /><br> <select name="whichname"> <option value="firstname">First Name</option> <option value="lastname">Last Name</option> </select> <input type="submit" name="submit" value="submit" /> </form>
</body></html>

Figure 1 shows what this form looks like in a Web browser. You can see that this sample form has three form elements:

  • A text field, which you can see from the code is called name

  • A drop-down list, which you can see from the code is named whichname and has values firstname and lastname

  • A Submit button

In the next section, you'll see that one column in the MySQL table is called firstname, and one is called lastname. They are the same values used in the drop-down list box, which will make my job easier in the C++ program.

  • + Share This
  • 🔖 Save To Your Account