Refer to Project Part2 for Logistics and Late Policy.
Build a user friendly Web interface to FANDANGOOSE.
A huge number of websites
are based largely on relational database system. The HTML pages a user browses
are generated from the database, and user actions and inputs result in
behind-the-scenes SQL queries and updates. Although the database-backed site
you will create is not likely to be as snazzy as a typical Web shopping or
auction site, the basic idea is the same.
Your Web front-end will interact with your PostgreSQL database using PHP and
call level SQL. You are also free to use other languages to implement your Web
interface. Please note that PHP is the only implementations supported by the
course staff. You are on your own if you use anything else.
The basic requirements of the web interface is outlined below:
1. Provide facility for a customer to login to the system using the username
and password for verification.
2. Allow new customers to create accounts (sign up). During the sign up
process, make sure to get all the information required to be stored for each
customer, including the credit card details.
3. Allow the webmaster of Concerto to login to the system using the special
username and password. Give options to him/her to add a new concert or delete
an old concert. The webmaster can also add new artists and new stadiums to the
database.
4. Customers wishing to view the details of concerts or to buy tickets should
go through the login process.
5. Allow the selection of concerts whose details are wished to be viewed by the
customer. Also, display the details of the respective performing artist if
requested.
6. When a customer wishes to buy tickets, get the details: number of tickets,
seating preference, credit card information. Verify the credit card information
against the information in the database. (which he/she provided during sign
up).
Note: Here we are trusting the information provided during sign up by the
customer, to avoid the overhead of maintaining another database for the
verifying the credit card information provided by standard companies.
7. Give the confirmation of the tickets purchased by the customer. Display the
shipping address at this time, and allow it to be updated by the customer if
he/she wishes to do so.
8. Give the option for customer or webmaster to logout of the system.
9. Give proper error messages as and when required.
Extra Credit:
1. Provide the facility for a customer to view all the bookings made by him/her
for any concert on FANDANGOOSE.
2. Provide support for the customer to cancel his/her bookings for any concert.
3. Allow the webmaster to view the total revenue generated for any concert.
This will include the income based on the tickets sold.
You are however free to add more features if desired.
Running Your Program on the Web:
The web server on linux.ic.ucsc.edu is Apache. Individual CGI-BIN directories
for CGI scriptshave been created for each student under
/local/cmps180/cgi-bin/Individual htdocs directories for HTML and PHP files have been created for each student under
/local/cmps180/htdocs/You should first create symbolic links to your directories, replacing username with your CATS username. The cd command puts you in your home directory. Do this command from the linux1.ic.ucsc.edu computer.
cd ln -s /local/cmps180/cgi-bin/username cmps180-cgi ln -s /local/cmps180/htdocs/username cmps180-htdocsRunning your executable CGI or PHP programs over the web will require your cats username and a password which is first four letters of your last name (lowercase)and the last four digits of your SID. The URL to access your html should simply be:
http://linux.ic.ucsc.edu/~username/filename.htmland to access your php files should be:
http://linux.ic.ucsc.edu/cgi-bin/cgiwrap/username/filename.phpwhere username is your cats username and filename is the name of your file such as "beers1.html" or "beers.php". The URL to access your CGI files should simply be
http://linux.ic.ucsc.edu/cgi-bin/cgiwrap/username/filenamewhere username is your CATS username and filename is the name of your file such as "beers1.cgi" or "beeers1.pl".
The way to run your scripts would be
chmod 700 filename1 filename2...or
chmod 700 *to be sure to set the proper permissions. Also add the line:
#!/usr/bin/phpto the top of the php script file.
Note that we are using port 80, not 8000. The latter is used for webct.
What to submit:PHP allows code to be included inline with HTML as in the example below. Blocks of PHP code are bracketed with "<?php" at the beginning and "?>" at the end to differentiate them from the HTML. PHP syntax is similar to Perl and C. Variable names start with $ and variable input from forms is retrieved by pre pending the form variable name with a $ as in the example below using "$beername" to obtain the "beername" input in the form.
Here is the example:
<html><body>
<h2> Find A Bar That serves a beer </h2>
<form name="input" action="beers.php" method="get">
Enter a Beer Name:
<input type="text" name="beername">
<input type="submit" value="Submit">
</form>
<?php
dl('pgsql.so');
// start of php code block embedded in html
$database = pg_Connect ("dbname=jsnook_beers user=jsnook");
if (!$database) {
echo "An error occured.<BR>";
}
else if ($submit == "Submit" AND $beername != "" AND $beername[0]){
$select = "SELECT * FROM sells WHERE beer LIKE '%" . $beername . "%'";
// Get bars from sells
$result = pg_exec ($database, $select );
if (!$result || (pg_numrows($result) < 1)) {
echo "I'm Sorry We Found No Records For You, Try Again<BR>";
exit;
}
listTable($result);
}
// End of code block
?>
</body></html>
<?php
// another code block for functions.
// Note global variables are shared amongst blocks
// display data from an SQL query result
function listTable($result) {
if (!$result) {
echo "No Data to List.\n";
return;
}
echo "<table border='1' cellpadding='3'>";
echo "<tr>";
// display headings
for ($j=0; $j < pg_numfields($result); $j++) {
echo "<th>" . pg_fieldname($result, $j) . "</th>";
}
echo "</tr>";
$num = pg_numrows($result);
if ($num > 30) $num = 30; // limit size of result displayed
// display each row of the result
for ($i=0; $i < $num; $i++) {
echo "<tr>";
$r = pg_fetch_row($result, $i);
for ($j=0; $j < count($r); $j++) {
echo "<td>$r[$j]</td>";
}
echo "</tr>";
}
echo "</table>";
}
// end of code block
?>