http://people.aero.und.edu/~userid/457/1/http://people.aero.und.edu/~userid/create commands), XML, and whatever languages‡, and
|
Background
This exercise includes activities of business-to-business (B2B) and business-to-consumer (B2C). B2B describes commerce transactions between businesses, such as between a manufacturer and a wholesaler, or between a wholesaler and a retailer. XML (eXtensible Markup Language) defines a standard way of encoding the structure of information in plain text format. With XML, financial information can be exchanged over the Internet conveniently. Whereas B2C refers to transactions conducted directly between a company and consumers. |
|
books.dtd, which defines the legal building blocks of the book list such as books.xml, is given as follows:
books.dtd
|
|---|
<!ELEMENT booklist (book+)> <!ELEMENT book (ISBN, title, price)> <!ELEMENT ISBN (#PCDATA)> <!ELEMENT title (#PCDATA)> <!ELEMENT price (#PCDATA)> |
books.xml is given as follows:
books.xml
|
|---|
<?xml version="1.0"?>
<booklist>
<book>
<ISBN>0134291255</ISBN>
<title>MySQL and PHP for the Web</title>
<price>24.54</price>
</book>
<book>
<ISBN>0596157134</ISBN>
<title>Learning PHP, MySQL, and LAMP</title>
<price>5.86</price>
</book>
<book>
<ISBN>1449325572</ISBN>
<title>LAMP: Linux, Apache, MySQL, and PHP</title>
<price>22.16</price>
</book>
<book>
<ISBN>020177061X</ISBN>
<title>Web Development with LAMP</title>
<price>14.40</price>
</book>
<book>
<ISBN>0321833899</ISBN>
<title>Linux, MySQL, and PHP Web Development</title>
<price>17.27</price>
</book>
</booklist>
|
upload.html in html or txt, is used to upload an XML file:
| Upload a Book List. | |
|---|---|
/home/wenchen/public_html/course/457/exercise/1/upload/”chmod 777 upload/so the Web can write the files to the folder.
/home/wenchen/public_html/course/457/exercise/1/upload.php
|
|---|
<html><body>
<?php
if ( $_POST['act'] == "Upload" ) {
header( "Content-type: text/html" );
if ( ( $_FILES[file][type] == "text/xml" ) &&
( $_FILES[file][size] < 50000 ) ) {
if ( $_FILES[file][error] <= 0 ) {
echo "Upload: <em>" . $_FILES[file][name] . "</em>";
echo "Type: <em>" . $_FILES[file][type] . "</em>";
echo "Size: <em>" . ceil( $_FILES[file][size] / 1024 ) . " Kb</em>";
move_uploaded_file( $_FILES[file][tmp_name], "upload/books.xml" );
echo "Stored in: <em>upload/books.xml</em>";
chmod( "upload/books.xml", 0755 );
}
else {
echo "Error: " . $_FILES[file][error];
print_r( $_FILES[file] );
}
}
else {
echo "Invalid file";
print_r( $_FILES[file] );
}
}
elseif ( $_POST['act'] == "Check the upload" ) {
header( "Location: upload/books.xml" );
}
elseif ( $_POST['act'] == "Help" ) {
header( "Content-type: text/html" );
system( "cat help.html" );
}
?>
</body></html>
|
create table” have to be submitted, where SQL is Structured Query Language and DDL is Data Definition Language.
create commands of database implementation are NOT submitted.