#2 create and populate a database && realistic and practical applications

The Chapter3 & Chapter4 of this book tells you how to create a realistic app on the web through the lab.

That is really amazing when you finished yourself. I will show you how to make it as follows.

FIRST OF ALL, we need a plan of how to make an application, generally speaking, you can following the steps like this(as we did it in the lab1):

1. Create a database and table for the app (the email list)

2. Create and edit a web form for the customer

3. Create and edit a PHP script to handle the web form

To Finish the application, we should start with the table, actually, it all starts with a database.

step 1 :

what you have to do is to use these command line with MySQL :

CREATE DATABASE elvis_store

Then you need to create a table inside the database, just like we did in the lab1, but beofore you create tables, Please

make sure you have selected the database or you will get an ERROR. This command may help you with it :

USE elvis_store

Next you can create table(s) inside this database, table structure is based on your application, In this app you can design the table like this:

CREATE TABLE email_list
(
    first_name VARCHAR (20) ,
    last_name VARCHAR (20) ,
    email VARCHAR (60)
);

It is quite simple, yeah ? Next we will move to step2:

step2 :

make a directory to store this application, you can name it lab2 or anything you want, and add some html files && css files to it :

/***    addemail.html     ***/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Make Me Elvis - Add Email</title>
    <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
    <img src="blankface.jpg" width="161" height="350" alt="" style="float:right" />
    <img name="elvislogo" src="elvislogo.gif" width="229" height="32" border="0" alt="Make Me Elvis" />
    <p>Enter your first name, last name, and email to be added to the <strong>Make Me Elvis</strong> mailing list.</p>
    <form method="post" action="addemail.php">
      <label for="firstname">First name:</label>
      <input type="text" id="firstname" name="firstname" /><br />
      <label for="lastname">Last name:</label>
      <input type="text" id="lastname" name="lastname" /><br />
      <label for="email">Email:</label>
      <input type="text" id="email" name="email" /><br />
      <input type="submit" name="Submit" value="Submit" />
    </form>
</body>
</html>

/***    style.css        ***/

body, td, th {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
}

If you run it on your apache Server , you will get a page like this :

Its just a simple form and serveral css. Very Simple. Now we have finished step2.

The only thing we need to notice is that this form‘s action = ‘addemail.php‘ which means it will send this form to the file on the Server.

lets move to the step3. you may probably know how to do it, yes create an edit addemail.php file on the Server.

Step3:

时间: 2024-10-08 17:00:37

#2 create and populate a database && realistic and practical applications的相关文章

#2 create and populate a database &amp;&amp; realistic and practical applications (PART 2)

Extends from the last chapter , This chapter takes a look at some real-world problems that can occur as you move your application from testing to a live website, Through this chapter you will learn more important PHP and SQL code. First Problem : Its

How to create a logical standby database based on a physical standby database

The related steps about how to create a phisical standby database please refer:   http://blog.csdn.net/waterxcfg304/article/details/35991771 /* How to create a logical standby database based on a physical standby database   */ 以下是主库: 下列语句可以用来检查SQL应用能

[odb-users] Create schema error (unknown database schema &#39;&#39;)

Boris Kolpackov boris at codesynthesis.comFri May 31 11:13:02 EDT 2013 Previous message: [odb-users] Create schema error (unknown database schema '') Next message: [odb-users] Create schema error (unknown database schema '') Messages sorted by: [ dat

Create schema error (unknown database schema &#39;&#39;)

Andrey Devyatka 4 years ago Permalink Raw Message Hi,Please tell me, can I use the static library in the following case: library.hpp:#ifndef _CPP_ODB_STATIC_LIBRARY_CPP_#define _CPP_ODB_STATIC_LIBRARY_CPP_#include <odb/database.hxx>odb::database* cr

HiveSQLException: Error while compiling statement: No privilege &#39;Create&#39; found for outputs { database:default }

今天用Hive的JDBC实例时出现了HiveSQLException: Error while compiling statement: No privilege 'Create' found for outputs { database:default }的错误,日志如下. org.apache.hive.service.cli.HiveSQLException: Error while compiling statement: No privilege 'Create' found for

Create Oracle 12c Template Database In Silent

1.静默文件 [[email protected] ~]$ cat create_template_db.rsp  [GENERAL] RESPONSEFILE_VERSION = "12.1.0" OPERATION_TYPE = "createTemplateFromDB" [createTemplateFromDB] SOURCEDB = "rhndb" SYSDBAUSERNAME = "system" SYSDBAP

CREATE DATABASE failed

由于环境需要, 故修改SQL Server 2012的默认的数据库的数据文件和日志文件的位置. 如下: 创建数据库, 遭遇报错. 错误信息: A file activation error occurred. The physical file name 'E:testaaa.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation. CREATE DATABASE failed.

CHAPTER 1 Introduction to database (第一章 数据库简介)

Chaper  Objectives  (章节目标) In this chapter you will learn:   (在这一章节中,你将学习) 1. Some common uses of database systems.   (数据库系统的一些普通扩法) 2.The characteristics of file-based systems. (基于文件系统的一些特点.) 3. The problems with the file-based systems.  (基于文件系统拥有的一

Create the Data Access Layer

https://docs.microsoft.com/en-us/aspnet/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/create_the_data_access_layer This tutorial describes how to create, access, and review data from a database using ASP.NET Web Forms an