Skip to content

Instantly share code, notes, and snippets.

@tdlmatias
Created March 25, 2015 01:01
Show Gist options
  • Save tdlmatias/358fbcb79ac20a6fb188 to your computer and use it in GitHub Desktop.
Save tdlmatias/358fbcb79ac20a6fb188 to your computer and use it in GitHub Desktop.
This testing PHP learning env
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/PHP-Developer.iml" filepath="$PROJECT_DIR$/.idea/PHP-Developer.iml" />
</modules>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitSharedSettings">
<option name="FORCE_PUSH_PROHIBITED_PATTERNS">
<list>
<option value="origin" />
</list>
</option>
</component>
<component name="VcsDirectoryMappings">
<mapping directory="$USER_HOME$/IdeaProjects/php-developer" vcs="Git" />
</component>
</project>
<!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">
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<title>Access Denied</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Access Denied </h1>
<p align="center">&nbsp;</p>
<h4 align="center" class="err">Access Denied!<br />
You do not have access to this resource.</h4>
</body>
</html>
<?php
/*
* admin.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* The code generates an HTML
* table that holds the name of each movie and person, along
* with ADD, EDIT, and DELETE links.
*/
//Start session
session_start();
//All the Database connection from this file
include_once(intermediate.php);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Movie Database </title>
<meta http-equiv="refresh" content="50; URL=http://localhost/PHP Developer/">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<style type="text/css" media="screen" >
<!--
th { background-color: #999;}
.odd_row { background-color: #EEE; }
.even_row { background-color: #FFF; }
-->
</style>
</head>
<body>
<?php include 'header.php'; ?>
<table style="width: 100%;">
<tr>
<th colspan="2">Movies <a href="movie.php?action=add"> [ADD] </a></th>
</tr>
<?php
$query = 'SELECT * FROM movie';
$result = mysql_query($query, $db) or die(mysql_error($db));
$odd = true;
while ($row = mysql_fetch_assoc($result)) {
echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">';
$odd = !$odd;
echo '<td style="width: 75%;">';
echo $row['movie_name'];
echo '</td><td>';
echo ' <a href="movie.php?action=edit&id=' . $row['movie_id'] . '">
[Edit]</a>';
echo ' <a href="delete.php?type=movie&id=' . $row['movie_id'] . '">
[DELETE]</a>';
echo '</td></tr>'; /*continue from here*/
}
?>
<tr>
<th colspan="2">People <a href="people.php?action=add"> [ADD] </a> </th>
</tr>
<?php
$query = 'SELECT * FROM people';
$result = mysql_query($query, $db) or die(mysql_error($db));
$odd = true;
while ($row = mysql_fetch_assoc($result)) {
echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">';
$odd = !$odd;
echo '<td style="width: 25%;">';
echo $row['people_fullname'];
echo '</td><td>';
echo ' <a href="people.php?action=edit&id=' . $row['people_id'] .
'"> [EDIT]</a>';
echo ' <a href=delete.php?type=people&id=' . $row['people_id'] .
'"> [DELETE]</a>';
echo '</td></tr>';
}
?>
</table>
<?php include 'footer.php'; ?>
</body>
</html>
<?php
//Start session
session_start();
//Check whether the session variable SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
header("location: access-denied.php");
exit();
}
?>
<?php
include "header.php";
//Start session
session_start();
//All the Database connection from this file
include_once(intermediate.php);
//getting the data from the database
$query = "SELECT movie_name, movie_year
FROM movie
WHERE movie_type = 5
ORDER BY movie_name";
$results = mysql_query($query)
or die (mysql_error());
echo "<table>\n";
while ($rows = mysql_fetch_assoc($results)) {
echo "<tr>\n";
foreach ($rows as $value) {
echo "<td>\n";
echo $value;
echo "</td>\n";
}
echo "</tr><br>\n";
}
echo "</table>\n";
//include here the footer page
include "footer.php";
//end of document
?>
<?php
/*
* commit.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* The code generates an HTML
* table that holds the name of each movie and person, along
* with ADD, EDIT, and DELETE links.
*/
//Start session
session_start();
//All the Database connection from this file
include_once(intermediate.php);
?>
<html>
<head>
<title>Commit </title>
</head>
<body>
<?php
switch ($_GET['action']) {
case 'add':
switch ($_GET['type']) {
case 'movie':
$query = 'INSERT INTO
movie
(movie_name, movie_year, movie_type, movie_leadactor, movie_director)
VALUES
("' . $_POST['movie_name'] . '",
"' . $_POST['movie_year'] . '",
"' . $_POST['movie_type'] . '",
"' . $_POST['movie_leadactor'] . '",
"' . $_POST['movie_director'] . '")';
break;
/*Adding script here to allow users to add and remove people*/
case 'people':
$query = 'INSERT INTO
people
(people_fullname, people_isactor, people_isdirector )
VALUES
("' . $_POST['people_name'] . '",
' . $_POST['people_isactor'] . ',
' . $_POST['people_isdirector'] . ')';
break;
}
break;
/* Add more to this file from here */
case 'edit':
switch ($_GET['type']) {
case 'movie':
$query = 'UPDATE movie SET
movie_name = "' . $_POST['movie_name'] . '",
movie_year = ' . $_POST['movie_year'] . ',
movie_type = ' . $_POST['movie_type'] . ',
movie_leadactor = ' . $_POST['movie_leadactor'] . ',
movie_director = ' . $_POST['movie_director'] . '
WHERE
movie_id = ' . $_POST['movie_id'];
break;
/*adding script to allow to edit the people table (update the people table on database)*/
case 'people':
$query = 'UPDATE people SET
people_fullname = "' . $_POST['people_fullname'] . '",
people_isactor = "' . $_POST['people_isactor'] . '",
people_isdirector = "' . $_POST['people_isdirector'] . '"
WHERE
people_id = ' . $_GET['id'];
break;
}
break;
/*to here*/
}
if (isset($query)) {
$result = mysql_query($query, $db) or die(mysql_error($db));
}
?>
<p>Done!</p>
<!-- HTML Forms allow you to drive the way users enter data -->
<?php header("Location: admin.php") ?>
</body>
</html>
<?php
/*
** This document was created and edited by iTechGeek
*/
define('DB_HOST', 'localhost');
define('DB_USER', 'admin_Geek2');
define('DB_PASSWORD', '3xsPs/_2h9QmQAVMY');
define('DB_DATABASE', 'moviesite');
?>
<?php
/*
* createmovie.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
//All the Database connection from this file
include_once(intermediate.php);
//create the main database if doesn't already exist
$create = mysql_query("CREATE DATABASE IF NOT EXISTS moviesite")
or die(mysql_error());
//make sure that the database is active
mysql_select_db("moviesite");
//create a "movie" table
$movie = "CREATE TABLE movie (
movie_id int(11) NOT NULL auto_increment,
movie_name varchar(255) NOT NULL,
movie_type tinyint(2) NOT NULL default 0,
movie_year int(4) NOT NULL default 0,
movie_leadactor int(11) NOT NULL default 0,
movie_director int(11) NOT NULL default 0,
PRIMARY KEY (movie_id),
KEY movie_type (movie_type,movie_year)
)";
$result = mysql_query($movie)
or die (mysql_error());
//create "movietype" table
$movietype = "CREATE TABLE movietype (
movietype_id int(11) NOT NULL auto_increment,
movietype_label varchar(100) NOT NULL,
PRIMARY KEY (movietype_id)
)";
$result = mysql_query($movietype)
or die (mysql_error());
//create "people" table
$people = "CREATE TABLE people (
people_id int(11) NOT NULL auto_increment,
people_fullname varchar(255) NOT NULL,
people_isactor tinyint(1) NOT NULL default 0,
people_isdirector tinyint(1) NOT NULL default 0,
PRIMARY KEY (people_id)
)";
$result = mysql_query($people)
or die(mysql_error());
echo "Movie Database successfully created!";
?>
<?php
/*
* date.php
* Copyright 2012 Tdlm <tdlm@tdlm-pc>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml/DTD/xhtml11-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> How many days is this month? </title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="Bluefish 2.2.2" />
</head>
<body>
<?php include "header.php"; ?>
<?php
$monthname = date("F");
echo "The month is : ";
echo $monthname;
echo "<br>";
echo "There are ";
$month = date("n");
if ($month == 1) echo "31";
if ($month == 2) echo "28 (unless it's a leap year)";
if ($month == 3) echo "31";
if ($month == 4) echo "30";
if ($month == 5) echo "31";
if ($month == 6) echo "30";
if ($month == 7) echo "31";
if ($month == 8) echo "31";
if ($month == 9) echo "30";
if ($month == 10) echo "31";
if ($month == 11) echo "30";
if ($month == 12) echo "31";
// this is a template: if ($month == ) echo ;
echo " days in this month.";
echo "<br>";
$monthsleft = 12-$month;
echo "There are ";
echo $monthsleft;
echo " months left in the year.";
?>
<?php include "footer.php"; ?>
</body>
</html>
<?php
include "header.php";
//Start session
session_start();
//All the Database connection from this file
include_once(intermediate.php);
//Alter the movie table to include running time, costs and takings fields
$query = 'ALTER TABLE movie ADD COLUMN (
movie_running_time TINYINT UNSIGNED NULL,
movie_cost DECIMAL(4,1) NULL,
movie_takings DECIMAL(4,1) NULL) ';
mysql_query($query, $db) or die(mysql_error($db));
//insert new data into the movie table for each movie
$query = 'UPDATE movie SET
movie_running_time = 101,
movie_cost = 81,
movie_takings = 242.6
WHERE
movie_id = 1';
//query every single table with new data
mysql_query($query, $db) or die(mysql_error($db));
$query = 'UPDATE movie SET
movie_running_time = 89,
movie_cost = 10,
movie_takings = 10.8
WHERE
movie_id = 2';
mysql_query($query, $db) or die(mysql_error($db));
$query = 'UPDATE movie SET
movie_running_time = 134,
movie_cost = NULL,
movie_takings = 33.2
WHERE
movie_id = 3';
mysql_query($query, $db) or die(mysql_error($db));
echo "Movie database successfully updated!";
/*First, the script used the ALTER TABLE command to add the appropriate fields to the existing movie
table, and then it used the UPDATE command to insert the new data into those fields.*/
//As the link says here am adding the footer information into my page
include "footer.php";
?>
<?php
//Include database connection details
//All the Database connection from this file
include_once(intermediate.php);
//create the reviews table
$query = 'CREATE TABLE reviews (
review_movie_id integer UNSIGNED NOT NULL,
review_date date NOT NULL,
reviewer_name varchar(255) NOT NULL,
review_comment varchar(255) NOT NULL,
review_rating tinyint UNSIGNED NOT NULL default 0,
PRIMARY KEY (review_movie_id))
ENGINE=MyISAM';
//testting if connecting to the database or output an error
mysql_query($query, $db) or die(mysql_error($db));
//insert new data into the reviews table
$query = <<<ENDSQL
INSERT INTO reviews
(review_movie_id, review_date, reviewer_name, review_comment, review_rating)
VALUES
(1, "2008-09-23", "John Doe", " I thought this was a great movie Even though my girlfriend made me see it against my will.", 4),
(2, "2008-09-23", "Billy Bob", " I liked Eraser head better.", 2),
(3, "2008-09-28", "Peppermint Patty", " I wish I’d have seen it sooner!", 5),
(1, "2008-09-23", "Marvin Martian", " This is my favorite movie. I didn’t wear my flair to the movie but I loved it anyway.", 5),
(2, "2008-09-23", "George B.", " I liked this movie, even though I Thought it was an informational video from my travel agent.", 3)
ENDSQL;
mysql_query($query, $db) or die(mysql_error($db));
echo 'Movie database successfully updated!';
?>
<?php
include "header.php";
/*
* delete.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* The code generates an HTML
* table that holds the name of each movie and person, along
* with ADD, EDIT, and DELETE links.
*/
//Start session
session_start();
//All the Database connection from this file
include_once(intermediate.php);
if (!isset($_GET['do']) || $_GET['do'] != 1) {
switch ($_GET['type']) {
case 'movie':
echo 'Are you sure you want to delete this movie?<br/>';
break;
case 'people':
echo 'Are you sure you want to delete this person?<br/>';
break;
}
echo '<a href=" ' . $_SERVER['REQUEST_URI'] . '&do=1">yes</a> ';
echo 'or <a href="admin.php">no</a>';
} else {
switch ($_GET['type']) {
case 'people':
$query = 'UPDATE movie SET
movie_leadactor = 0
WHERE
movie_leadactor = ' . $_GET['id'];
$result = mysql_query($query, $db) or die(mysql_error($db));
$query = 'DELETE FROM people
WHERE
people_id = ' . $_GET['id'];
$result = mysql_query($query, $db) or die(mysql_error($db));
?>
<p style="text-align: center;">Your person has been deleted.
<a href="movie_index.php">Return to index</a></p>
<?php
break;
case 'movie':
$query = 'DELETE FROM movie
WHERE
movie_id = ' . $_GET['id'];
$result = mysql_query($query, $db) or die(mysql_error($db));
?>
<p style="text-align: center;">Your movie has been deleted.
<a href="movie_index.php">Return to Index</a></p>
<?php
break;
}
}
include "footer.php";
?>
<?php
/*
* firstprog.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>untitled</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="Bluefish 2.2.2" />
</head>
<body>
<?php include "header.php"; ?>
<?php
echo "If this work, great!";
echo "And still I am ok";
//Everything that goes inside the html/php code embeded is circunvented by ('')
// insted of ("")
echo "<table width='100%' border='2' bgcolor='#FFFFFF'>";
echo "<tr>";
echo "<td width='50%'>";
echo "font face='Verdana, Arial' size='2'>";
echo "First Name:";
echo "</font></td>";
echo "<td width='50%'>";
echo "<font face='Verdana, Arial' size='2'>";
echo $_POST["fname"];
echo "</font></td>";
echo "</tr>";
echo "</table>";
?>
<?php include "footer.php"; ?>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Submit Form </title>
</head>
<body>
<form action="formprocess1.php" method="post">
<table>
<tr>
<td>Name</td>
<td><input type="text" name="name" /></td>
</tr><tr>
<td colspan="2" style="text-align: center;">
<input type="submit" name="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Greetings Earthling </title>
</head>
<body>
<form action="formprocess2.php" method="post">
<table><!-- When checked, it passes the value on to the
$_POST array, but otherwise it isn’t sent by the browser
at all. This is a great way to represent Boolean typed data. -->
<tr>
<td>Name</td>
+ <td><input type="text" name="name" /></td>
</tr><tr>
<td>Greetings</td>
<td><!-- Options list -->
<select name="greeting">
<option value="Hello">Hello</option>
<option value="Hola">Hola</option>
<option value="Bonjour">Bonjour</option>
<option value="Ola">Ola</option>
<option value="Buenos">Buenos</option>
<option value="Ndeipi">Ndeipi</option>
<option value="Makadini">Makadini</option>
</select>
</td>
</tr><tr>
<td> </td>
<td><!-- Debuging information -->
<input type="checkbox" name="debug" checked="checked" />
Display Debug Info
</td>
</tr><tr><!-- -->
<td colspan="2" style="text-align: center">
<input type="submit" name="submit" value="Submit" />
</td>
</tr>
</table>
<form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Add/Search Entry</title>
<style type="text/css">
<!--
td {vertical-align: top;}
-->
</style>
</head>
<body>
<form action="formprocess3.php" method="post" enctype="multipart/form-data">
<table>
<tr>
<td>Name</td>
<td><input type="text" name="name"></td>
</tr><tr>
<td>Movie Type</td>
<td><!-- Selection list of movie types -->
<select name="movie_type">
<option value="">Select a Movie type...</option>
<option value="Action">Action</option>
<option value="Drama">Drama</option>
<option value="Comedy">Comedy</option>
<option value="Sci-Fi">Sci-Fi</option>
<option value="War">War</option>
<option value="Other">Other...</option>
</select>
</td>
</tr><tr>
<td> </td>
<td><input type="checkbox" name="debug" checked="checked" />
Display Debug info
</td>
</tr><tr>
<td colspan="2" style="text-align: center;">
<input type="submit" name="submit" value-="Search" />
<input type="submit" name="submit" value="Add" />
</td>
</tr>
</table>
</form>
<!-- contiinue from here -->
<!--<tr>Test form</tr>-->
//<?php ?>
</body>
</html>
<?php
session_unset();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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>Multipurpose Form</title>
<style type="text/css">
<!--
td {vertical-align: top;}
-->
</style>
</head>
<body>
<?php include 'header.php'; ?>
<!-- These fields are not displayed by the browser to the user, but their
values are submitted with the rest of the form fields’ data. This is but
one way to pass data between forms, though it is very common. -->
<form action="form4a.php" method="post">
<table>
<tr>
<td>Name</td>
<td><input type="text" name="name" /></td>
</tr><tr>
<td>Item Type</td>
<td>
<input type="radio" name="type" value="movie" checked="checked" />
Movie<br/>
<input type="radio" name="type" value="actor" /> Actor<br/>
<input type="radio" name="type" value="director"/> Director<br/>
</td>
</tr><tr>
<td>Movie Type<br/><small>(if applicable)</small></td>
<td>
<select name="movie_type">
<option value="">Select a movie type...</option>
<option value="Action">Action</option>
<option value="Drama">Drama</option>
<option value="Comedy">Comedy</option>
<option value="Sci-Fi">Sci-Fi</option>
<option value="War">War</option>
<option value="Other">Other...</option>
</select>
</td>
</tr><tr>
<td> </td>
<td>
<input type="checkbox" name="debug" checked="checked" />
Display Debug info
</td>
</tr><tr>
<td colspan="2" style="text-align: center;">
<input type="submit" name="submit" value="Search" />
<input type="submit" name="submit" value="Add" />
</td>
</tr>
<!-- 146
Chapter 5: Form Elements: Letting the User Work with Data -->
</table>
</form>
<?php include 'footer.php'; ?>
</body>
</html>
<?php
//Make sure the user selected a movie type if they are adding another movie
//If not, then send them back to the first form.
if ($_POST['submit'] == 'Add') {
if ($_POST['type'] == 'movie' && $_POST['movie_type'] == '') {
header('Location: form4.php');
}
}
?>
<html>
<head>
<title>Multi-Choice Form</title>
<style type="text/css">
<!--
td {vertical-align: top;}
-->
</style>
</head>
<body>
<?php
//Show a form to collect more info if the user is adding something
if ($_POST['submit'] == 'Add') {
echo '<h1>Add ' . ucfirst($_POST['type']) . '</h1>';
?>
<!-- Get the form layout here -->
<form action="form4b.php" method="post">
<input type="hidden" name="type" value="<?php echo $_POST['type']; ?>"/>
<table>
<tr>
<td>Name</td>
<td>
<?php echo $_POST['name']; ?>
<input type="hidden" name="name" value="<?php echo $_POST['name']; ?>"/>
</td>
</tr>
<?php
if ($_POST['type'] == 'movie') {
?>
<tr>
<td>Movie</td>
<td>
<?php echo $_POST['movie_type']; ?>
<input type="hidden" name="movie_type" value="<?php echo $_POST['movie_type']; ?>"/>
</td>
</tr><tr>
<td>Year</td>
<td><input type="text" name="year" value=" " /></td>
</tr><tr>
<td>Movie Description</td>
<?php
} else {
echo '<td>Biography</td>';
}
?>
<td><textarea name="extra" rows="5" cols="60"></textarea></td>
</tr><tr>
<td colspan="2" style="text-align: center;">
<?php
if (isset($_POST['debug'])) {
echo '<input type="hidden" name="debug" value="on" />';
}
?>
<input type="submit" name="submit" value="Add" />
</td>
</tr>
</table>
</form>
<?php
//The user is just searching for something
// this all documents is quite new to need to get around
// to unserstant it bettter
} else if ($_POST['submit'] == 'Search') {
echo '<h1>Search for ' . ucfirst($_POST['type']) . '</h1>';
echo '<p>Searching for ' . $_POST['name'] . '...</p>';
}
if (isset($_POST['debug'])) {
echo '<pre>';
print_r($_POST);
echo '</pre>';
}
?>
</body>
</html>
<html>
<head>
<title>Multipurpose Form</title>
<style type="text/css">
<!--
td {vertical-align: top;}
-->
</style>
</head>
<body>
<?php
/*
**This set of scripts is designed around a simple idea: passing data
**through multiple scripts from form to form. The key to this has been
**input elements with their type attribute set to hidden.
*/
if ($_POST['type'] == 'movie') {
echo '<h1>New ' . ucfirst($_POST['movie_type']) . ': ';
} else {
echo '<h1>New ' . ucfirst($_POST['type']) . ': ';
}
echo $_POST['name'] . '</h1>';
echo '<table>';
if ($_POST['type'] == 'movie') {
echo '<tr>';
echo '<td>Year</td>';
echo '<td>' . $_POST['year'] . '</td>';
echo '</tr><tr>';
echo '<td>Movie Description</td>';
} else {
echo '<td>Biography</td>';
}
echo '<td>' . nl2br($_POST['extra']) . '</td>';
echo '</tr>';
echo '</table>';
if (isset($_POST['debug'])) {
echo '<pre>';
print_r($_POST);
echo '</pre>';
}
?>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Say My Name</title>
</head>
<body>
<?php
echo '<h1>Hello ' . $_POST['name'] . '!</h1>';
?>
<pre><!-- ??? what is this "pre" tagging for? -->
<strong>DEGUG:</strong>
<?php print_r($_POST); ?>
</pre>
<!-- -->
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Greetings Earthling</title>
</head>
<body>
<?php
include "header.php";
echo '<h1>' . $_POST['greeting'] . ' ' . $_POST['name'] . '!</h1>';
if (isset($_POST['debug'])) {
echo '<pre><strong>DEBUG:</strong>' . "\n";
print_r($_POST);
echo '</pre>';
}
?>
</body>
</html>
<div align="center">
<font size="4">Welcome to my movie review site!</font>
<br />
<?php
echo "Today is ";
echo date("F j");
echo ", ";
echo date("Y");
?>
<!-- With this header I can display the sane message in many pages as if
I like, as long as it invokes the "include" php function to display it in
plain html-->
<br>
<font size="2">
<?php
//this will look into system clock and display a great accordingly to the time
// present
if ((date("G") >= 5) AND (date("G") <= 11)) echo "Good Morning!";
if ((date("G") >=12) AND (date("G") <= 18)) echo "Good Afternoon!";
if ((date("G") >=19) AND (date("G") <= 4)) echo "Good Evening!";
?>
</font>
</div>
/*This file is created to control the access file--
<?php
/*
* index.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
/* Script that have to execute before the all document*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Welcome to Movie Review | Rating Site</title>
<meta http-equiv="refresh" content="50; URL=http://localhost/PHP Developer/">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="/stylesheet/styleformat.css">
</head>
<body>
<!-- HTML content comment -->
<?php include "header.php"; ?>
<?php echo '<br>'; ?>
<!-- Need to use styling to get his page the way I want it to look -->
<!-- So I decide to place it all in a div -->
<div id='body'; >
<?php include "linking.php";
echo '<br>';
?>
</div>
<div id='footer'; >
<?php include "footer.php"; ?>
</div>
</body>
</html>
<?php
/*
* intermediate.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* The code generates an HTML
* table that holds the name of each movie and person, along
* with ADD, EDIT, and DELETE links.
*/
//Start session
session_start();
//Include database connection details
//require_once make shore that the function only runs once on the server!
require_once('config.php');
/*connect to MySQL without showing the Database details by importing the details
** from another file holding all permission and user files*/
$db = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$db) {
die('Failed to connect to server: ' . mysql_error());
}
/*Then make sure you are connecting to the right database*/
//Select database
mysql_select_db(DB_DATABASE) or die(mysql_error($db));
/* Done */
?>
<?php
/*Create a PHP program that prints the lead actor and director for each movie in the database.
*
* leadactor.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*
*connect to MySQL; note weave used our own parameters- you should use
* your own for hostname, user, and password */
//All the Database connection from this file
include_once(intermediate.php);
//make sure we're using the right database
mysql_select_db("moviesite");
//Create a function to get lead actor
function get_leadactor($lead_actor) {
global $actorname;
$query2 = "SELECT people_fullname
FROM people
WHERE people.people_id = $lead_actor";
$results = mysql_query($query2)
or die(mysql_error());
$rows = mysql_fetch_array($results);
extract ($rows);
$actorname = $people_fullname;
}
//Create a function to get director
function get_director($director) {
global $directorname;
$query2 = "SELECT people_fullname
FROM people
WHERE people.people_id = '$director'";
$results = mysql_query($query2)
or die (mysql_error());
$rows = mysql_fetch_array($results);
extract($rows);
$directorname = $people_fullname;
}
//Now add a header to the document
echo "<table border='1'>\n";
echo "<tr>\n";
echo "<td><strong>Movie Name</strong></td>";
echo "<td><strong>Lead Actor</strong></td>";
echo "<td><strong>Director</strong></td>";
echo "</tr>";
//now here get the movies list
$query2 = "SELECT * FROM movie";
$results = mysql_query($query2)
or die(mysql_error());
while ($rows = mysql_fetch_assoc($results)) {
extract($rows);
//now call the functions to get specific info
get_leadactor($movie_leadactor);
get_director($movie_director);
//now build a table
echo "<tr>\n";
echo "<td>\n";
echo $movie_name;
echo "</td>\n";
echo "<td>";
echo $actorname;
echo "</td>\n";
echo "<td>\n";
echo $directorname;
echo "</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
include "footer.php";
//End of document
?>
<html>
<head>
<title>Is it a leap year?</title>
</head>
<body>
<?php
include "header.php";
$leapyear = date("L");
if ($leapyear == 1) echo "Hooray! Its a leap year!";
else echo "Aww, sorry, mate. No leap year this year.";
include "footer.php";
?>
</body>
</html>
Copyright (c) 2006, PHPSense.com
All rights reserved.
This license is a legal agreement between you and PHPSense.com for the use
of PS_FTPClass.php (the "Software"). By obtaining the Software you
agree to comply with the terms and conditions of this license.
PERMITTED USE
You are permitted to use, copy, modify, and distribute the Software and its
documentation, with or without modification, for any purpose, provided that
the following conditions are met:
1. A copy of this license agreement must be included with the distribution.
2. Redistributions of source code must retain the above copyright notice in
all source code files.
3. Redistributions in binary form must reproduce the above copyright notice
in the documentation and/or other materials provided with the distribution.
4. Any files that have been modified must carry notices stating the nature
of the change and the names of those who changed them.
5. Products derived from the Software must include an acknowledgment that
they are derived from PHPSense.com in their documentation and/or other
materials provided with the distribution.
INDEMNITY
You agree to indemnify and hold harmless the authors of the Software and
any contributors for any direct, indirect, incidental, or consequential
third-party claims, actions or suits, as well as any related expenses,
liabilities, damages, settlements or fees arising from your use or misuse
of the Software, or a violation of any terms of this license.
DISCLAIMER OF WARRANTY
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR
IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF QUALITY, PERFORMANCE,
NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
LIMITATIONS OF LIABILITY
YOU ASSUME ALL RISK ASSOCIATED WITH THE INSTALLATION AND USE OF THE SOFTWARE.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS OF THE SOFTWARE BE LIABLE
FOR CLAIMS, DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE. LICENSE HOLDERS ARE SOLELY RESPONSIBLE FOR DETERMINING THE
APPROPRIATENESS OF USE AND ASSUME ALL RISKS ASSOCIATED WITH ITS USE, INCLUDING
BUT NOT LIMITED TO THE RISKS OF PROGRAM ERRORS, DAMAGE TO EQUIPMENT, LOSS OF
DATA OR SOFTWARE PROGRAMS, OR UNAVAILABILITY OR INTERRUPTION OF OPERATIONS.
<div align='center' style='float:left; width:40%;'>
<a href='comedies.php'> Comedies movies</a><br>
<a href='date.php'> Date</a><br>
<a href='firstprog.php'> My first Program</a><br>
<a href='leadactor.php'> About the First Actor</a><br>
<a href='leapyear.php'> Leap Year or Not !</a><br>
<a href='login.php'> You can Login Here</a><br>
<a href='movies.php'> What is you Fav Movie?</a><br>
<a href='select.php'> Selection</a><br>
<a href='select2.php'> Second Selection</a><br>
<a href='sorting.php'> Data sorted</a><br>
<a href='table1.php'>Table data 1</a><br>
<a href='table2.php'>Table data 2</a><br>
<a href='table3.php' title='This is Movies Page!'>Table data 3</a><br>
</div>
<?php
/**
** Show each movie in the database on its own page, and give the user links in a page 1, page 2 . .
** type navigation system. Hint: Use OFFSET to control which movie is on which page.
** * leadactor.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*
*connect to MySQL; note weave used our own parameters- you should use
* your own for hostname, user, and password **/
//All the Database connection from this file
include_once(intermediate.php);
//make sure we're using the right database
mysql_select_db("moviesite");
//get our starting point for the query through the URL variable "offset"
/*Notice: Undefined index: offset in /home/tdlm/Developer/PHP Developer/linkingpage.php on line 36
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 1' at line 4 [solve this]*/
$offset = $_REQUEST['offset'];
$query = 'SELECT movie_name, movie_year
FROM movie
ORDER BY movie_name
LIMIT $offset, 1';
//printing the results
$results = mysql_query($query)
or die (mysql_error());
echo "<table>\n";
while ($rows = mysql_fetch_assoc($results)) {
echo "<tr>\n";
foreach($rows as $value) {
echo "<td>\n";
echo $value;
echo "</td>\n";
}
//built the table here and then populate it with data
echo "</tr></br>\n";
}
//with link pages
echo "</table>\n";
echo "<a href='page.php?offset=0'>Page 1 </a><br>";
echo "<a href='page.php?offset=1'>Page 2 </a><br>";
echo "<a href='page.php?offset=2'>Page 3 </a><br>";
//End of document
?>
<?php
//All the Database connection from this file
include_once(intermediate.php);
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$login = clean($_POST['login']);
$password = clean($_POST['password']);
//Input Validations
if($login == '') {
$errmsg_arr[] = 'Login ID missing';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}
//If there are input validations, redirect back to the login form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: login-form.php");
exit();
}
//Create query
$qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result) == 1) {
//Login Successful
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
$_SESSION['SESS_LAST_NAME'] = $member['lastname'];
session_write_close();
header("location: member-index.php");
exit();
}else {
//Login failed
header("location: login-failed.php");
exit();
}
}else {
die("Query failed");
}
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login Failed</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Login Failed </h1>
<p align="center">&nbsp;</p>
<h4 align="center" class="err">Login Failed!<br />
Please check your username and password</h4>
</body>
</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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login Form</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p>&nbsp;</p>
<form id="loginForm" name="loginForm" method="post" action="login-exec.php">
<table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="112"><b>Login</b></td>
<td width="188"><input name="login" type="text" class="textfield" id="login" /></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input name="password" type="password" class="textfield" id="password" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login" /></td>
</tr>
</table>
</form>
</body>
</html>
<?php
/*
* login.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
session_unset();
//Login control document
// it compares the data on the database before validate
// and allow the user to login
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Please Login In </title>
<meta http-equiv="content-type" conten="text/html;charset=utf-8" />
<meta name="generator" content="Bluefish 2.2.2" />
</head>
<body>
<?php
//add another with welcome message
include "header.php";
?>
<!-- Making up a new form to show the validation of
the PHP program -->
<form method="post" action="movie1.php">
<p>Enter you UserName:
<input type="text" name="user">
</p>
<p>Enter your Password
<input type="password" name="pass">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
<!-- Now adding extra form to add styling form to the form -->
<!-- Somehow the stylinga applied to this document is not taking
The expected effect debugg needed -->
<form method="post" action="movie1.php">
<p>Enter your font choice:
<select name="font">
<option value="Verdana">Verdana</option>
<option value="Arial">Arial</option>
<option value="Times News Roman">Times News Roman</option>
<option value="consolas">Consolas</option>
</select>
</p>
<p>Enter your font size:
<select name="size">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</p>
<p>
<select name="menu">
<option value="black">Black</option>
<option value="red">Red</option>
<option value="green">Green</option>
<option value="purple">Purple</option>
<option value="blue">Blue</option>
</select>
</p>
</form>
<?php include "footer.php"; ?>
</body>
</html>
body {
font: 11px Verdana, Arial, Helvetica, sans-serif;
color: #666666;
margin: 0px;
padding: 20px 10px 0px;
}
.textfield {
font-size: 11px;
color: #333333;
background: #F7F7F7;
border: 1px solid #CCCCCC;
padding-left: 1px;
}
h1 {
color: #99CC00;
margin: 0px 0px 5px;
padding: 0px 0px 3px;
font: bold 18px Verdana, Arial, Helvetica, sans-serif;
border-bottom: 1px dashed #E6E8ED;
}
a {
color: #2D3954;
font-size: 11px;
}
a:hover {
color: #99CC00;
}
.err {
color: #FF9900;
}
th {
font-weight: bold;
text-align: left;
}
<?php
//Start session
session_start();
//Unset the variables stored in session
unset($_SESSION['SESS_MEMBER_ID']);
unset($_SESSION['SESS_FIRST_NAME']);
unset($_SESSION['SESS_LAST_NAME']);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Logged Out</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Logout </h1>
<p align="center">&nbsp;</p>
<h4 align="center" class="err">You have been logged out.</h4>
<p align="center">Click here to <a href="login-form.php">Login</a></p>
</body>
</html>
<?php
/*
* makinPizza.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
?>
<?php
//One example of a class file
class Pizza {
public $dough;
public $toppings;
public function MakeDough($dough) {
$this->dough = $dough;
//rollout $this->dough
}
public function addToppings($toppings) {
$this->toppings = $toppings;
//chop $this->toppings;
//place $this->toppings on dough;
}
public function bake() {
//bake pizza
return true;
}
public function make_pizza($dough, $toppings) {
//make pizza
$step1 = $this->MakeDough($dough);
if ($step1) {
$step2 = $this->addToppings($toppings);
}
if ($step2) {
$step3 = $this->bake();
}
}
}
//End of the document
?>
<?php
require_once('auth.php');
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Index</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Welcome <?php echo $_SESSION['SESS_FIRST_NAME'];?></h1>
<a href="member-profile.php">My Profile</a> | <a href="logout.php">Logout</a>
<p>This is a password protected area only accessible to members. </p>
</body>
</html>
<?php
require_once('auth.php');
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My Profile</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>My Profile </h1>
<a href="member-index.php">Home</a> | <a href="logout.php">Logout</a>
<p>This is another secure page. </p>
</body>
</html>
<?php
/*
* movie.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* The code generates an HTML
* table that holds the name of each movie and person, along
* with ADD, EDIT, and DELETE links.
*/
//Start session
session_start();
//All the Database connection from this file
include_once(intermediate.php);
//modify this file to enables you to edit the database(movie)
//add this following script
if ($_GET['action'] == 'edit') {
//retrieve the record's information
$query = 'SELECT
movie_name, movie_type, movie_year, movie_leadactor, movie_director
FROM
movie
WHERE
movie_id = ' . $_GET['id'];
$result = mysql_query($query, $db) or die(mysql_error($db));
extract(mysql_fetch_assoc($result));
} else {
//set value to blank
$movie_name = '';
$movie_type = 0;
$movie_year = date('Y');
$movie_leadactor = 0;
$movie_director = 0;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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" />
<!-- change the title and add some more content -->
<title><?php echo ucfirst($_GET['action']); ?> Movie </title>
</head>
<body><!-- Change the details in the form to GET data from Movie -->
<?php include "header.php"; ?>
<form action="commit.php?action=<?php echo $_GET['action']; ?>&type=movie" method="post">
<table><!-- -->
<tr>
<td>Movie Name</td>
<td><input type="text" name="movie_name" /></td>
</tr><tr>
<td>Movie Type</td>
<td><select name="movie_type">
<?php
//select the movie type information
$query = 'SELECT
movietype_id, movietype_label
FROM
movietype
ORDER BY
movietype_label';
$result = mysql_query($query, $db) or die(mysql_error($db));
//populate the select options with the result
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $value) {
//change the script structure to accomodate more functions with if statement
if ($row['movietype_id'] == $movie_type) {
echo '<option value="' . $row['movietype_id'] . '" selected="selected">';
} else {
echo '<option value="' . $row['movietype_id'] . '">';
}
echo $row['movietype_label'] . '</option>';
}
}
?>
</select></td>
</tr><tr>
<td>Movie Year</td>
<td><select name="movie_year">
<?php
// populate the select option with years
// explain [change this value]
for ($yr = date("Y"); $yr >= 1970; $yr--) {
if ($yr == $movie_year) {
echo '<option value="' . $yr . '" selected="selected">' . $yr .
'</option>';
} else {
echo '<option value="' . $yr . '">' . $yr . '</option>';
}
} /*To display year in php after declare the function year its necessary to call is using
echo function to present it on the Browser */
?>
</select></td>
</tr><tr>
<td>Lead Actor</td>
<td><select name="movie_leadactor">
<?php
//select actor records
$query = 'SELECT
people_id, people_fullname
FROM
people
WHERE
people_isactor = 1
ORDER BY
people_fullname';
$result = mysql_query($query, $db) or die(mysql_error($db));
//populate the select options with the results
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $value) {
if ($row['people_id'] == $movie_leadactor) {
echo '<option value="' . $row['people_id'] .
'" selected="selected">';
} else {
echo '<option value="' . $row['people_id'] . '">';
}
echo $row['people_fullname'] . '</option>';
//add values here to allow data selection
//echo '<option value="' . $row['people_id'] . '">';
//echo $row['people_fullname'] . '</option>';
}
}
?>
</select></td>
</tr><tr>
<td>Director</td>
<td><select name="movie_director">
<?php
//select director records from database
$query = 'SELECT
people_id, people_fullname
FROM
people
WHERE
people_isdirector = 1
ORDER BY
people_fullname';
$result = mysql_query($query, $db) or die(mysql_error($db));
// populate the select options with the results
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $value) {
if ($row['people_id'] == $movie_director) {
echo '<option value="' . $row['people_id'] .
'" selected="selected">';
} else {
echo '<option value="' . $row['people_id'] . '">';
}
echo $row['people_fullname'] . '</option>';
//echo '<option value="' . $row['people_id'] . '">';
//echo $row['people_fullname'] . '</option>';
}
}
?>
</select></td>
</tr><tr>
<td colspan="2" style="text-align: center;">
<!-- Insert some php script here -->
<?php
if ($_GET['action'] == 'edit') {
echo '<input type="hidden" value="' . $_GET['id'] . '" name="movie_id" />';
}
?><!-- also edit the input function value="Add" here as -->
<input type="submit" name="submit" value="<?php echo ucfirst($_GET['action']); ?>" />
</td>
</tr>
<!-- continue here -->
</table>
</form>
<?php include "footer.php"; ?>
</body>
</html>
<?php
/*
* movie1.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
/**
* <?php
* //Add to lines to add styling into the text format using cookies storage
* if (!isset($_POST['pref'])) {
* preferences($_COOKIE);
* }
* if ($_POST['pref'] == 'Y') {
* setcookie('font', $_POST['font'], time()+60);
* setcookie('size', $_POST['size'], time()+60);
* setcookie('color', $_POST['color'], time()+60);
* }
*
* ?>
**/
//Now will use forms to make our page a little bit more
// interactive, by allowing our user to fill the form
// delete this line: setcookie('username', 'Joe', time()+60);
session_start();
//$_SESSION['username'] = $_POST['user'];
//$_SESSION['userpass'] = $_POST['pass'];
//$_SESSION['authuser'] = 0;
//It must get 0 always to the authenticatioon be verified
//Another way to apply text format
/*$_SESSION['font'] = $_POST['font'];
$_SESSION['size'] = $_POST['size'];
$_SESSION['color'] = $_POST['color']; */
//check username and password info
if (($_SESSION['username'] == 'Joe') and
($_SESSION['userpass'] == '12345')) {
$_SESSION['authuser'] = 1;
} else {
echo "Sorry, but you don't have permission to view
this page, you loser!";
exit();
}
//Script part to control the user access to the system
// delete this line $_SESSION['username'] = "Joel1234";
//delete this line: $_SESSION['authuser'] = 1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Find my favourite Movie!</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Bluefish 2.2.2" />
</head>
<body>
<?php
//add another with welcome message
include "header.php";
?>
<?php
// Add another line
$myfavmovie = urlencode("Life of Brian");
// How to link up two documents using the url
//echo "<a href='movieSite.php?favmovie=Stripe'>";
// Alter this line to show "Life of Brian" instead
// of showing 'Stripe'
echo "<a href='movieSite.php?favmovie=$myfavmovie'>";
echo "Click here to see information about my favourite movie!";
echo "</a>";
//This brings over the favourite movies list
//Add more information about your movies
echo "<br>";
/* Comments this lines out
echo "<a href='movieSite.php?movienum=5'>";
echo "Click here to see my top 5 movies.";
echo "</a>";
echo "<br>";
//change the following
echo "<a href='movieSite.php?movienum=10'>";
echo "Click here to see my top 10 movies.";
echo "</a>";
End of comment line */
// Now comment this lines out
/*echo "<a href='movieSite.php'>";
echo "Click here to see my top 10 movies.";
echo "</a>";
echo "<br />";
echo "<a href='movieSite.php?sorted=true'>";
echo "Click here to see my top 10 movies, sorted alphabetically";
echo "</a>"; */
echo "Or choose how many movies you would like to see: ";
// need to verify what page I'm closing here with </a>
echo "</a>";
echo "<br>";
?>
<form method="post" action="movieSite.php">
<p>Enter number of movies (up to 10):
<input type="text" name="num">
<br>
Chech here if you want the list sorted alphabetically:
<input type="checkbox" name="sorted">
</p>
<input type="submit" name="Submit" value="Submit">
</form>
<p>
<div>Do you want to save these preferences for the next time you log in?
</div>
<input type="checkbox" name="pref" value="y">
</p>
<?php include "footer.php"; ?>
</body>
</html>
<?php
/*
* movie_details.php
*
* Copyright 2012 root <root@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
include "header.php";
//Start session
//All the Database connection from this file
include_once(intermediate.php);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Movie Details</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Bluefish 2.2.2" />
</head>
<body>
<?php
//function to generate ratings
function generate_ratings($rating) {
$movie_rating = '';
for ($i = 0; $i < $rating; $i++) {
$movie_rating .= '<img src="star.png" alt="star"/>';
}
return $movie_rating;
}
// take in the id of a director and return his/her full name
function get_director($director_id) {
global $db; //This will allow the program to connect to the database and grab
// the data needed to accomplish the tas asked by the script or user input
$query = 'SELECT
people_fullname
FROM
people
WHERE
people_id = ' . $director_id;
//after runn this query grab the result and test if it runns with success
$result = mysql_query($query, $db) or die(mysql_error($db));
//If not error found then grab the data result from $director_id and place it in a row
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
// take in the id of a lead actor and return his/her full name
function get_leadactor($leadactor_id) {
global $db; //This will allow the program to connect to the database and grab
// the data needed to accomplish the tas asked by the script or user input
$query = 'SELECT
people_fullname
FROM
people
WHERE
people_id = ' . $leadactor_id;
//after runn this query grab the result and test if it runns with success
$result = mysql_query($query, $db) or die(mysql_error($db));
//If not error found then grab the data result from $director_id and place it in a row
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
// take in the id of a movie type and return the meaningful textual
// description
function get_movietype($type_id) {
global $db; //This will allow the program to connect to the database and grab
// the data needed to accomplish the tas asked by the script or user input
$query = 'SELECT
movietype_label
FROM
movietype
WHERE
movietype_id = ' . $type_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
//If not error found then grab the data result from $director_id and place it in a row
$row = mysql_fetch_assoc($result);
extract($row);
return $movietype_label;
}
// function to calculate if a movie made a profit, loss or just broke even
function calculate_differences($takings, $cost) {
//To calculate the profit made by selling the movies
$difference = $takings - $cost;
if ($difference < 0) {
$color = 'red';
$difference = '$' . abs($difference) . ' million';
}elseif ($difference > 0) {
$color = 'green';
$difference = '$' . $difference . ' million';
}else {
$color = 'blue';
$difference = 'broke even';
}
return '<span style="color' . $color . ';">' . $difference . '</span>';
}
/*connect to MySQL without showing the Database details by importing the details
** from another file holding all permition and user files*/
$db = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$db) {
die('Failed to connect to server: ' . mysql_error());
}
/*Then make sure you are connecting to the right database*/
//Select database
mysql_select_db(DB_DATABASE) or die(mysql_error($db));
// retrieve information with query as follow
$query = 'SELECT
movie_name, movie_year, movie_director, movie_leadactor,
movie_type, movie_running_time, movie_cost, movie_takings
FROM
movie
WHERE
movie_id = ' . $_GET['movie_id'];
$result = mysql_query($query, $db) or die(mysql_error($db));
//after run this query grab the result and test if it runs with success
$row = mysql_fetch_assoc($result);
$movie_name = $row['movie_name'];
$movie_director = get_director($row['movie_director']);
$movie_leadactor = get_leadactor($row['movie_leadactor']);
$movie_year = $row['movie_year'];
$movie_running_time = $row['movie_running_time'] . ' mins';
$movie_takings = $row['movie_takings'] . ' millions';
$movie_cost = $row['movie_cost'] . ' million';
$movie_health = calculate_differences($row['movie_takings'], $row['movie_cost']);
/*Quering the database from two different table join the output in one single table
//And present in a nice single table on browser */
/*Display information */
echo <<<ENDHTML
<html>
<head>
<title>Details and Reviews for: $movie_name </title>
</head>
<body>
<div style="text-align: center;">
<h2>$movie_name</h2>
<h3><em>Details</em></h3>
<table cellpadding="2" cellspacing="2" style="width: 70%; margin-left: auto; margin-right: auto;">
<tr>
<td>
<strong>Title</strong></strong>
</td>
<td>$movie_name</td>
<td>
<strong>Release Year</strong></strong>
</td>
<td>$movie_year</td>
</tr>
<tr>
<td>
<strong>Movie Director</strong>
</td>
<td>$movie_director</td>
<td>
<strong>Cost</strong>
</td>
<td>$movie_cost<td/>
</tr>
<tr>
<td>
<strong>Lead Actor</strong>
</td>
<td>$movie_leadactor</td>
<td>
<strong>Takings</strong></td>
<td>$$movie_takings<td/>
</tr>
<tr>
<td>
<strong>Running Time</strong>
</td>
<td>$movie_running_time</td>
<td><strong>Health</strong></td>
<td>$movie_health<td/>
</tr>
</table>
ENDHTML;
// retrieve reviews for this movie
$query = 'SELECT
review_movie_id, review_date, reviewer_name, review_comment, review_rating
FROM
reviews
WHERE
review_movie_id = ' . $_GET['movie_id'] . '
ORDER BY
review_date DESC';
$result = mysql_query($query, $db) or die(mysql_error($db));
// display the reviews
echo <<< ENDHTML
<h3><em>Reviews</em></h3>
<table cellpadding="2" cellspacing="2" style="width: 90%; margin-left: auto; margin-right: auto;">
<tr>
<th style="width: 7em;">Date</th>
<th style="width: 10em;">Reviewer</th>
<th>Comments</th>
<th style="width: 5em;">Rating</th>
</tr>
ENDHTML;
while ($row = mysql_fetch_assoc($result)) {
$date = $row['review_date'];
$name = $row['reviewer_name'];
$comment = $row['review_comment'];
$rating = generate_ratings($row['review_rating']);
echo <<<ENDHTML
<tr>
<td style="vertical-align:top; text-align: center;">$date</td>
<td style="vertical-align:top;">$name</td>
<td style="vertical-align:top;">$comment</td>
<td style="vertical-align:top;">$rating</td>
</tr>
ENDHTML;
}
/*split the tail end of the heredoc block that outputs the movie’s information so that there
are two: */
echo <<<ENDHTML
</div>
</body>
</html>
ENDHTML;
?>
</body>
</html>
<?php
/*
* movie_details.php
*
* Copyright 2012 root <root@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
include "header.php";
//Start session
session_start();
//Include database connection details
//All the Database connection from this file
include_once(intermediate.php);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Movie Details</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Bluefish 2.2.2" />
</head>
<body>
<?php
// take in the id of a director and return his/her full name
function get_director($director_id) {
global $db; //This will allow the program to connect to the database and grab
// the data needed to accomplish the tas asked by the script or user input
$query = 'SELECT
people_fullname
FROM
people
WHERE
people_id = ' . $director_id;
//after runn this query grab the result and test if it runns with success
$result = mysql_query($query, $db) or die(mysql_error($db));
//If not error found then grab the data result from $director_id and place it in a row
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
// take in the id of a lead actor and return his/her full name
function get_leadactor($leadactor_id) {
global $db; //This will allow the program to connect to the database and grab
// the data needed to accomplish the tas asked by the script or user input
$query = 'SELECT
people_fullname
FROM
people
WHERE
people_id = ' . $leadactor_id;
//after runn this query grab the result and test if it runns with success
$result = mysql_query($query, $db) or die(mysql_error($db));
//If not error found then grab the data result from $director_id and place it in a row
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
// take in the id of a movie type and return the meaningful textual
// description
function get_movietype($type_id) {
global $db; //This will allow the program to connect to the database and grab
// the data needed to accomplish the tas asked by the script or user input
$query = 'SELECT
movietype_label
FROM
movietype
WHERE
movietype_id = ' . $type_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
//If not error found then grab the data result from $director_id and place it in a row
$row = mysql_fetch_assoc($result);
extract($row);
return $movietype_label;
}
// function to calculate if a movie made a profit, loss or just broke even
function calculate_differences($takings, $cost) {
//To calculate the profit made by selling the movies
$difference = $takings - $cost;
if ($difference < 0) {
$color = 'red';
$difference = '$' . abs($difference) . ' million';
}elseif ($difference > 0) {
$color = 'green';
$difference = '$' . $difference . ' million';
}else {
$color = 'blue';
$difference = 'broke even';
}
return '<span style="color' . $color . ';">' . $difference . '</span>';
}
/*connect to MySQL without showing the Database details by importing the details
** from another file holding all permition and user files*/
$db = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$db) {
die('Failed to connect to server: ' . mysql_error());
}
/*Then make sure you are connecting to the right database*/
//Select database
mysql_select_db(DB_DATABASE) or die(mysql_error($db));
// retrieve information with query as follow
$query = 'SELECT
movie_name, movie_year, movie_director, movie_leadactor,
movie_type, movie_running_time, movie_cost, movie_takings
FROM
movie
WHERE
movie_id = ' . $_GET['movie_id'];
$result = mysql_query($query, $db) or die(mysql_error($db));
//after run this query grab the result and test if it runs with success
$row = mysql_fetch_assoc($result);
$movie_name = $row['movie_name'];
$movie_director = get_director($row['movie_director']);
$movie_leadactor = get_leadactor($row['movie_leadactor']);
$movie_year = $row['movie_year'];
$movie_running_time = $row['movie_running_time'] . ' mins';
$movie_takings = $row['movie_takings'] . ' millions';
$movie_cost = $row['movie_cost'] . ' million';
$movie_health = calculate_differences($row['movie_takings'], $row['movie_cost']);
/*Quering the database from two different table join the output in one single table
//And present in a nice single table on browser */
/*Display information */
echo <<<ENDHTML
<html>
<head>
<title>Details and Reviews for: $movie_name </title>
</head>
<body>
<div style="text-align: center;">
<h2>$movie_name</h2>
<h3><em>Details</em></h3>
<table cellpadding="2" cellspacing="2" style="width: 70%; margin-left: auto; margin-right: auto;">
<tr>
<td>
<strong>Title</strong></strong>
</td>
<td>$movie_name</td>
<td>
<strong>Release Year</strong></strong>
</td>
<td>$movie_year</td>
</tr>
<tr>
<td>
<strong>Movie Director</strong>
</td>
<td>$movie_director</td>
<td>
<strong>Cost</strong>
</td>
<td>$movie_cost<td/>
</tr>
<tr>
<td>
<strong>Lead Actor</strong>
</td>
<td>$movie_leadactor</td>
<td>
<strong>Takings</strong></td>
<td>$$movie_takings<td/>
</tr>
<tr>
<td>
<strong>Running Time</strong>
</td>
<td>$movie_running_time</td>
<td><strong>Health</strong></td>
<td>$movie_health<td/>
</tr>
</table>
</div>
</body>
</html>
ENDHTML;
?>
<?php include "footer.php"; ?>
</body>
<?php
/*
* moviedata.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
//All the Database connection from this file
include_once(intermediate.php);
//make sure we're using the right database
mysql_select_db("moviesite");
//insert data into "movie" table
$insert = "INSERT INTO movie (movie_id, movie_name, movie_type, " .
"movie_year, movie_leadactor, movie_director) " .
"VALUES (1, 'Bruce Almighty', 5, 2003, 1, 2), " .
"(2, 'Office Space', 5, 1999, 5, 6), " .
"(3, 'Grand Canyon', 2, 1991, 4, 3)";
$result = mysql_query($insert)
or die (mysql_error());
//insert data into "movietype" table
$type = "INSERT INTO movietype (movietype_id, movietype_label) " .
"VALUES (1,'Sci Fi'), " .
"(2, 'Drama'), " .
"(3, 'Adventure'), " .
"(4, 'War'), " .
"(5, 'Comedy'), " .
"(6, 'Horror'), " .
"(7, 'Action'), " .
"(8, 'Kids')" ;
$results = mysql_query($type)
or die(mysql_error());
//insert data into “people” table
$people = "INSERT INTO people (people_id, people_fullname, " .
"people_isactor, people_isdirector) " .
"VALUES (1, 'Jim Carrey', 1, 0), " .
"(2, 'Tom Shadyac', 0, 1), " .
"(3, 'Lawrence Kasdan', 0, 1), " .
"(4, 'Kevin Kline', 1, 0), " .
"(5, 'Ron Livingston', 1, 0), " .
"(6, 'Mike Judge', 0, 1)";
$results = mysql_query($people)
or die(mysql_error());
echo "Data inserted successfully!";
?>
<?php
/*
* movies.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Testing PHP </title>
</head>
<body>
<?php include "header.php"; ?>
<?php
define("FAVMOVIE", "The Life of Brian");
echo "My favourity movie is ";
echo FAVMOVIE;
?>
<?php include "footer.php"; ?>
</body>
</html>
<?php
/*
* movieSite.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
session_start();
//check to see if user has logged in with a valid passowrd
if ($_SESSION['authuser'] !=1) {
echo "Sorry, but you don't have permmission to view this page, you loser!";
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Testing Movie Site - <?php echo $_REQUEST['favmovie']; ?></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="Bluefish 2.2.2" />
</head>
<body>
<?php
//add another with welcome message
include "header.php";
?>
<?php
//We will experiment with array
//So I'll make this lines comment now
$favmovies = array("Life of Brian",
"Stripes",
"Office Space",
"The Holy Grail",
"Matrix",
"Terminator 2",
"Star Wars",
"Close Encounters of the Third Kind",
"Sixteen Candles",
"Caddyshack");
/*Delete this lines
function listmovies_1() {
echo "1. Life if Brian<br />";
echo "2. Stripes<br />";
echo "3. Office Space<br />";
echo "4. The Holy Grail<br />";
echo "5. Matrix<br />";
}
function listmovies_2() {
echo "6. Terminador 2<br />";
echo "7. Star Wars<br />";
echo "8. Close Encounters of the Third Kind<br />";
echo "9. sixteen Cnadles<br />";
echo "10. Caddyshack<br />";
}
The comment out finish here*/
//pay special attention when declaring functions
if (isset($_REQUEST['favmovie'])) {
echo "Welcome to our site, ";
//delete this: echo $_SESSION['username'];
//add this on to deal with cookies session
// authentication
//delete this line: echo $_COOKIE['username'];
//replace with this new one
echo $_SESSION['username'];
echo "<br />";
// delete this line: define("FAVMOVIE", "The Life of Brian");
echo "My favourity movie is ";
echo $_REQUEST['favmovie'];
//$favmovie = 'Stripe';
//echo $favmovie;
echo "<br />";
$movierate = 5;
echo "My movie rating for this movie is: ";
echo $movierate;
} else {
//changing this line here
echo "MY top". $_POST['num']. " movies are: <br>";
//"My top 10 movies are:<br />";
if (isset($_REQUEST['sorted'])) {
sort($favmovies);
}
//to show the list of movies sorted
echo "<table>";
$numlist = 1;
while ($numlist <= $_POST["num"]) {
//echo $numlist;
echo "<tr>";
echo "<td>";
echo pos($favmovies);
echo "</td>";
next($favmovies);
//echo "<br>";
$numlist = $numlist + 1;
echo "</tr>";
}
echo "</table>";
/* Comment out this line
echo "My top";
echo $_REQUEST['movienum'];
echo " movie are:";
echo "<br />";
listmovies_1();
if ($_REQUEST['movienum'] == 10) listmovies_2();
*/
/* delete this lines
foreach ($favmovies as $currentvalue) {
echo $currentvalue;
echo "<br />\n";
} */
}
?>
<?php include "footer.php"; ?>
</body>
</html>
#
# Table structure for table 'members'
#
CREATE TABLE `members` (
`member_id` int(11) unsigned NOT NULL auto_increment,
`firstname` varchar(100) default NULL,
`lastname` varchar(100) default NULL,
`login` varchar(100) NOT NULL default '',
`passwd` varchar(32) NOT NULL default '',
PRIMARY KEY (`member_id`)
) TYPE=MyISAM;
#
# Dumping data for table 'members'
#
INSERT INTO `members` (`member_id`, `firstname`, `lastname`, `login`, `passwd`) VALUES("1", "Jatinder", "Thind", "phpsense", "ba018360fc26e0cc2e929b8e071f052d");
PK3Z9
PHP-Login/PK�y�4�N�qOPHP-Login/access-denied.phpmP_O�07�;}�m� ��l$
$��3�<��d�������� �S�w�wqo�2MW�9�U�|�_<N��������|<�O ��kH��N�4Z(��� XAT�r^�uX�Cc7<}��F+j��2�_�0��M./��q�U�%��D�Ѩ�w`y�n�4��+�K��hBMAz(�A��F�'ްǐ�:�D: �7� b�-��pr�e��PK�c�5�TI���τ)��zk�Ja�9���J���BW ��G����S���ѹxH� JJnt�2-�\�+�1/[���2%��Z=S��kۚ�L�m
�C� P!�_���f� �6�)e{6_�PK-Z9�� PHP-Login/auth.php}�A �@��
���{eB����1B6}�K���T���V�C�.����0��ь\'��ʀF�e]Ye�2��.��s���@�|=p�J�s��bƲ4N��!K� 54
5VjUml����� �d��wG���(�-���?�����;y��xe�scḱ�m8-��X��^�_��S��#7Z}PK�Z9�y�r�PHP-Login/config.phpm�1
�0�Y�;���7hQ"����IQ�$�@���t���V��&q$�g��B8{�Z��d2o�z�<ɮI���RU҈~�R-g�N���ͫE�f�g�Ӗ2
�oJ��B��YPK Mt5�VHD�? PHP-Login/license.txt�UM��6�S���n�l6��4X�+�l攒A�U� ��>�ž�g����ƨ�ׯ���N���xW��O?�A�� �9=�l�i�G8���ga��8hLE���
�S �]�u��6z8j��Ɏ������a�at: ���E�Ǎrnv���v;U�����O`7�2��v>�rJ a��a�����G3�}ؠ��y��j3�9@��_R��J�%�ú�a�D���ftM�7B��)���f�߄\7�f3�V����Am��\QDM����0a��|J����?X"<���Ԥ`��0 ��m{$+��"�V�Q5?΀y�ok�jQ;:���jF�1� ���|����o��Ύ}����X��CBm��
� ���+ @�\]goM��g��[&DܘN�'���0�+�X��y����Pc~@�-���*���j��3��z}?`��zC�>�ӽ�J��xR���yr;5��*/�w��U��f�h�yJqื��z%�� ��n�X�&l{\���R� FxP՟�=6����&
u`��� ���NN��;^z���g�t�W�(��;wYd�պ�pǼ+{����[��M=ќ�]�Y�0��՘�(�U��u5D��T�H,��h)1��F|�5�������(�:\��=�7�88jj�<K�Ew���@�a@4FmL��J?kժ=8= ��G�՚�8߃� ]<t�GO�μ.� W�ll35�I�t���m7E�0���|eR��ZP.9٢�7D��Ŝ����.���\f��%��Y������sɋ2�:�*O��"���\��cr�������̢ ���}Y�"���E&W,�99�f��.$��O�P��Dv/� d]�2E ��� g��:a�̳�π ��Y�)q��)����b�����(>��,��R�@6��(1�c�����-$.�b��Q0K���FeA��,��aY�2K�\oQ��{� G8*˷��`�V�{� �k�P7� ����<[x{PN��)���0x��Us"b�b19$���<67G�i!%s^��fJT,Ǚ�%��ۀ��1d�W�oleA�W�ߎ�'��$[��xBa��Z�Ӝ$٤���lx���_xs�){d"������:�n!B�39���PK|N9UD��{�PHP-Login/login-exec.php�UMo�8=�@�k�S����v�V���@��R�=AK#�-E�$7-��w�!��&E�r�͛7��?o�u�����(3L�Ak�H� +�����5n����EW)�a+��䍔��%ƅ�8��+���aaHɫ)���X)vGLC�i�[&8bZP�Q�W��(S��� {L��%���U!�.1�dB�.��3�5�;�ح�eS�_1�m���d~L?\dW/.>eI��q�}�H�/'�\�!���
�ݞ�P�*�PЗzE"2 U�ɡ���S�@؄^\K�X�iwJ���6����8K"�j���d+��=����ӳ�Lrÿ�it����-6S��&f �lT=%�
nAM��g��/~�W�`�&'ڨ��.��wF���[�x�֬�9�t�M�6G]|Z��y��k�{� 4�� )`���Y �&�jd��-]�C��
M�%V P{|������L�m���E�!0\��3d0������H� v��A��̅,��xe��Â���o�b�~{�G� �J�-e�ᮡ���o;zl���HVWߠ5L`
��h�d����:J�t���q�F��aǬ�����h4�g`�V���E�;*�|їΥ��V�7��]G'�dӁ��#ݨ��8KΒ�+򜜦KRC����I�x�Y����|N���,O���<0Gcg�f��jNl��$'k@�k�2;�\�2Mt��@� �("���AM��貫�j�z8G/��ߦ�#�l��{�T A�2�A�сb�
�`�5�.�|W$D#� �L��IJs?V�s�o��<�w�H�+z/��%W�HV�c�g�y��O{�P8ʃ�䲀o{��3��' �(\�_�G0�K]�c�֭�{�?:O��+���PK�z�4�.u�OPHP-Login/login-failed.phpmP_O�07�;}�m� ��n<80��3�>��d ];������ A�S�w�w�`��f�9�T)X��.R`�oÔ�Y6����qQx ��I�F ���+��kΛ� �ah�g/|�jE-�Pt� *���,�w��.�G'�L&=��(ڷBТ���Fj
�}� ���0��}y)�CJ�3�x|5 "��"I
� ���TXļ��z��τ�Q�b�0̝c`Q%��^�+�y�g���1���n��xD��kJ�u�r-�^蕫ob^w�џ1�J83�z*8�W��X*��o`o������^�1��[���Lj��|�PKj��4%/����PHP-Login/login-form.php�RM��0�#���7�Bj٤�E � 8:�plcO7��·ڕ"��3��{o�'��)�I��"���v7�&���0�-����ӎd邔�k/Q�c��)� �}�X�uiw�wd�Wv�XYl�o:S���_��{�s��/fp��j5���E<[@NbuN��4&��%���,v?����қd�|�J2JX�B�
�;s���7���p��ԿI��PP�[#N
��{J��z�(� R��zd� zp6)����Ӯ_��ۇ�٘!�bď��h�³�0mcB�5>��::8$p�:�����#��N
l
z�XPR'�4�\�ch��5��K���BH},�ݐ{��>_ �ҍQ�ń�ewt�W�o9���61[�\�B�� o'��+P+��$(A��D#o�C��E5�Ӆ��=a��I�5��r}�_9�?ϫX�j%N_�m̞�:�t���C��߱�D}0-Y��!� PK�Qt5��i�=PHP-Login/loginmodule.css�Q�n� �^��Io�u?Z�fO�{���Q0�:�e�>̭mz�c$�;�j�>��|v�*is�$�H^@3*�<iNŒ<�8��C �&2�y�sg%���b� ���9���e��.'+������-��� �d�'�ק��i��i�&���G�<�47����E��DC$��~$�����8��(��‚��V&< xȭV�F��%� :�����3jzp��M�-�A'=��ڧ��aw5/�{u}�f�YUY65m���������[ET���A�?PK�N9�C���PHP-Login/logout.php}Rmk�0��B��M���`k�4���& �$.[#(�56S$O:���OrR�F�'��{��N�o�>?{��!�hm��������]�jq��"�a*��h��6X@�N���|�����p:�q��8ߧ��pp�|�e8�g���8�/lt��w~�L���C
%�%<<ޏ�}`�߮��|���G�!3Bي�_!9O' XIT�|�݆۫P��f|�"�| :� *��nwk�l�
O��t�0�Ÿk$���$���� ��� ?�F�#��¸u$����ͧN1���*�����=ƴ��2�$+� J�� �zU��.�an-�2a���%KDb@N��Zr��x��};A�tC�j��� d�R ˝e4��^-mݍy���)C.�u�B�O��Rl��
�aG:��W����LhHC,N� ��Y��k3�R1�� ��ݦ �PK�N9@J�-�xPHP-Login/member-index.phpmQ_k�0^ ��&�l͔A��[��@��ƣcž�b��J�%�}�Jv:�0�N��;)�6e3�2�t�����j$�T��b�v2L�� ~=��e߷ (�R���i�� 8���q>����K�^A��̈�J����ņ+����N��tj�ȳ;~�Z�'_ʀ�a��[w��J�6�N4�{zFQ�B�с�w�f�&�)���}�0�3qϞ@^
c�iups�~D ��"I
�5V4�� <Ǽ?s�Jֿ�4�0�e]��0̭e`P%�R�Ж�Ā��ųt��%�Am7C�ޣ�u����K o���n�����b�yy���������d�:�ȓ�%L�� ����dX�na��1)�h]�G���#�\�f�����FX{Ҧ'J�
еjA�9Z+
�4��6��7݌/�uo�gPK�z�4�ZFg&PHP-Login/member-profile.phpmQ_k�0^ �ᦗt�fJ�Yb�2H�P<�> žDb��I�%�}�JvR�0�t��'i~��v<���O����«��H�a0�4���h�q�(_6� �Ѱ��u�m,������e���U�,� ��+R����wL�_8?��:�n��'~�ZY$�˄�1Ӛj�{�c������M�Ӂ>�Q�qo�Dt/�7g k %�E�p��xdϠ��y�\y����L���Z�Hc�p���;�q·Nie~�t�˙�{e[w��{u�<�4z�H (X�{@/�/���>�7��YA�g�+�. 6[t�25��be��H��P!��h���:"�L[�RyKKx�:�Њ=����3]��/�WPK�Z9�'}4+PHP-Login/mysql.sql��Ak�0��B�Ç=��A-�Z�n��fm�頧�� �T����F�N#�7���xd���� ��J� ��$@�gV�M�BZgld���,
I$|H"ȿ.s� ��v�ʁqe��lϱ�tI �$ �N�v�����s5Rq�`oT�*l������Q�s=x���N{�@�\h��ٖJ�^}Ó�Wv�ŋ0��K��u��]E���x.�(����S״���!6N�QF N�r�u��;4�l����a��ֶ�.��T1^�Й�Q���J�u.���&S�.�)ze�<�3�n�ڻ *�9��PK�Y9���HPHP-Login/readme.html�UMo�8=�@���=쥲�|,bW1��R �]�ב�Q�Ԓ�ew���!)���@w؃j4����;1�i���q��%<����� �I��v5K��r��/�?@6���a�
'�b2M�0��k&i�uݨ�i�N�ӭ��<�?&�r�N�y�q[Ke�N�d��8�c22�������l��n8�ʡr�r����t7t�u�G���bƢ�V'��7�$B깜p����<�O�n'��4��AË$9�����ي��@�5�4]c ���L�W��&_�=� :QR�R�E#V��_�U(J-�����x6���Wg53k�&p�l����p�8j}�_�x�Ph�!���?�pVh��$�vN�Ta9�rx��qq���:/��3���B����H���j|s��7��3�I�ɓJoМ.��'��v|N�����=�h�oQ������4���&i��a%$Z��:A��P�W!p�)�f�Jlp���'ג��RL��+�5U ,+�.^�τ���9V0�>�� 8m��v .e�K��6X��΋2@��?�S yJB�� ��u4��6u�� XQ7�_�>�4�X��{�����U&�?�����Q塍�A�j� B��ԭr6੪c�R�w��}��o�ż��ɱ<�R���v�3�nq��$�m�?��;-��7%����~�Q�ӌ���`etHz�c�د�<��= �k��-4F;2q7l�'���|sz�;Uʖct�w.N_7a��.P��a��j�~�q��
�O�
���L��Ԧ5�գ.+����4�[^]N?�� ����a ߳O���x�$����Ty�lG��-�S.+���ˇ��OF�bj��갆�6�hU�}�۶��R%5��(�p��J�5� ��:
�B`tA��#X�����۸��.��ބ.PY��`��WPK'M9#���� PHP-Login/register-exec.php�V�nI}�J�edi`Œ��%Y'&6� 9�ap�`E���z�s���,�����0��<�j�S��N]�?�T���_N�=� S4j-ʂn�)����{EW7.��S��6g��E��R4LHM8��Z(Lʂc7"H&r�DC��L ڔ
�IA���*�e9�S� S
΁Y��H>~e�d�`e�d�1�qkp�#�>�^I�V=��&R_ﮓ�Q��m�n��@��x4u��a�L�\"�:��KORA�^��Z/�u�]�������s<�5!�(�A#� -�o���$��Ю����a<jI�;at� 6��}�v�]^ׅ��E�B�F�r��L���!+U>�;��X ��_��D�5d\"+�gڨ�=R"F����(l� 4I��'��4��E�Io���Qi�����͂��Ԫ)d����������iS������Y�r$�!��~���賣9�!rR.D�-��6��i�.U� ����"�W�0�Um����I����I;_��<�Jp�\����U #eT����U�����4�W�(������يx���A=��?��Ү@�C����y^����uك�sx?�ECZBQș�ˣ�\"�b'Һ��3� ��{:��x�6D։G7������{�1������h:�$瑷�:>���f��V5�MײmD�4�n<���D�k�^��u�c�T�� ЧZ���"a��\x�BL����v ��|����&�{ :-n��8��G!0�nf�7P�Aa*���sF�0��U
�:¿zv�z�؛Z$�(�Ǔۇh4����L��idE��EԼ�k% &\�� {�$�Pu;��������� ��U�
���������ƣ� \E� �Ƿ�I���.�"� ��d ��#C��qxs?���_dQ?��\C��� O_ڣ�N�s�ֶ���~���m���k�Aל�hY-���*T`�G�������wZ�~��PK St5"�ͧ�PHP-Login/register-form.php�TkO�0� ���B$R��Mtm��R6��P�i���rc���ę��V�}vPt�﵏�9��v�4�ҝ�-ʹ�2kC��?h�l�;۝7g��я�D&p��S�� ����q��|�2��C�ހ�"��Ʋ�q�
��I?`<�����T3<���j��e處�uj(rҹ�"����i�Z�b{f��1f��C{�O�o}ԕ�a��F˔!��G�- v��FDif|��wr��5`�e�,��O�\�����$x�"Ŧ>n=�4�j�@1�#m���1��X�R1��r<�t����t��~�w���pxq}��� .����گ�۳�1Q�,ׂB�%kh��_+���HB�� Ѷ�L)��nm*#a�  ����L��A����:�%mp�w+j8�D��;��ܕ�h���iYtw'�G�"i1�Զ�$tm�#�f\�<�`a��ڵ @ǐ�`0��D>:n4L��L�ȆD��ږa�v"%��d棣"�) �Q:JUF.��s���+klE+k4��$�Ly��V�U��)g����%��V��^���>�L_l�/^�_�y��驍{���Ē�od�nZ��1���� i�� <�ϛxX��GW&Sn{���
_�(|�%�%��W��|�:���TooXf�Dd6�/�%I�7���A�A� �� �PKVQt5-��9�PHP-Login/register-success.phpu�QO�0��M�׾C%��P�A�D���b��Z�Fci�^���Rؒ=�SOsϹ�i���S^|��PQ�a�z��ρ���r���D�%�0N��FhΗ� XE�\s�����,���|�wE>|��$ÒJ���%#q_k��?�DqO�Ɍ��g�$�����O�rk E� 9�RF�'��7 +�:�T9��Wq1�~)Ҙ=�V���o/���ܦ� �ƃO+�U���i�U��e�1��1hQ��Q��U�Ā��hI�X�Ӗ����0M��Sh��m6Uò\+9�.2 �Ë�v-)mg(Lx3��?� PK3Z9
0�APHP-Login/PK�y�4�N�qO ��(PHP-Login/access-denied.phpPK-Z9��  ���PHP-Login/auth.phpPK�Z9�y�r� ���PHP-Login/config.phpPK Mt5�VHD�?  ��?PHP-Login/license.txtPK|N9UD��{� ��PHP-Login/login-exec.phpPK�z�4�.u�O ��� PHP-Login/login-failed.phpPKj��4%/���� ��@ PHP-Login/login-form.phpPK�Qt5��i�= ��LPHP-Login/loginmodule.cssPK�N9�C��� ���PHP-Login/logout.phpPK�N9@J�-�x ���PHP-Login/member-index.phpPK�z�4�ZFg& ��oPHP-Login/member-profile.phpPK�Z9�'}4+ ��PHP-Login/mysql.sqlPK�Y9���H ��uPHP-Login/readme.htmlPK'M9#����  ��TPHP-Login/register-exec.phpPK St5"�ͧ� ��bPHP-Login/register-form.phpPKVQt5-��9� ��B"PHP-Login/register-success.phpPK��#
<?php
/*
* untitled.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>untitled</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Geany 0.21" />
</head>
<body>
<?php
//Here I create my object
$table1 = new Pizza();
$table1->make_pizza('hand_tossed', 'pepperoni');
if ($table1->bake()) {
//Delivery the pizza to table1;
}
else {
echo "ups, looks like you should have gone eat fast food insted.";
//this script wont work as it is on trial.
}
?>
</body>
</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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Readme</title>
<style type="text/css">
<!--
body {
font: 11px/1.4em Verdana, Arial, Helvetica, sans-serif;
}
h1 {
color: #99CC00;
margin: 0px 0px 5px;
padding: 0px 0px 3px;
font: bold 18px Verdana, Arial, Helvetica, sans-serif;
border-bottom: 1px dashed #E6E8ED;
}
h2 {
color: #99CC00;
margin: 15px 0px 5px;
padding: 0px 0px 3px;
font: bold 14px Verdana, Arial, Helvetica, sans-serif;
border-bottom: 1px dashed #E6E8ED;
}
a {
color: #2D3954;
font-size: 11px;
}
a:hover {
color: #99CC00;
}
-->
</style>
</head>
<body>
<h1>Readme</h1>
<p>Below is a brief description of all PHP files you will find in the download archive.</p>
<ol>
<li>config.php - This script contains the database connection details. Edit this file to specify your own database's connection details.</li>
<li>register-form.php - A simple registration form</li>
<li>register-exec.php - Handler script for the the above form. This script will create member accounts for you.</li>
<li>login-form.php - Login form</li>
<li>login-exec.php - Handler script for the above login form. This script authenticates the login details and then sets up a session for the user.</li>
<li>logout.php - Script used to logout a user from the session.</li>
<li>member-index.php - Sample password protected page.</li>
<li>member-profile.php - Sample password protected page.</li>
<li>auth.php - Include this script at the top of any page you want to password protect. This script checks whether the user is logged in or not.</li>
</ol>
<h2>Notes</h2>
<ul>
<li>Make sure that you edit the <b>config.php</b> file and change the connections details to match your own environment.</li>
<li>The script is meant to be a teaching tool for PHP newbies and is not meant to be used in production environments.</li>
</ul>
</body>
</html>
<?php
//Start session
session_start();
//Include database connection details
require_once('config.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$fname = clean($_POST['fname']);
$lname = clean($_POST['lname']);
$login = clean($_POST['login']);
$password = clean($_POST['password']);
$cpassword = clean($_POST['cpassword']);
//Input Validations
if($fname == '') {
$errmsg_arr[] = 'First name missing';
$errflag = true;
}
if($lname == '') {
$errmsg_arr[] = 'Last name missing';
$errflag = true;
}
if($login == '') {
$errmsg_arr[] = 'Login ID missing';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}
if($cpassword == '') {
$errmsg_arr[] = 'Confirm password missing';
$errflag = true;
}
if( strcmp($password, $cpassword) != 0 ) {
$errmsg_arr[] = 'Passwords do not match';
$errflag = true;
}
//Check for duplicate login ID
if($login != '') {
$qry = "SELECT * FROM members WHERE login='$login'";
$result = mysql_query($qry);
if($result) {
if(mysql_num_rows($result) > 0) {
$errmsg_arr[] = 'Login ID already in use';
$errflag = true;
}
@mysql_free_result($result);
}
else {
die("Query failed");
}
}
//If there are input validations, redirect back to the registration form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: register-form.php");
exit();
}
//Create INSERT query
$qry = "INSERT INTO members(firstname, lastname, login, passwd) VALUES('$fname','$lname','$login','".md5($_POST['password'])."')";
$result = @mysql_query($qry);
//Check whether the query was successful or not
if($result) {
header("location: register-success.php");
exit();
}else {
die("Query failed");
}
?>
<?php
session_start();
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login Form</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) {
echo '<ul class="err">';
foreach($_SESSION['ERRMSG_ARR'] as $msg) {
echo '<li>',$msg,'</li>';
}
echo '</ul>';
unset($_SESSION['ERRMSG_ARR']);
}
?>
<form id="loginForm" name="loginForm" method="post" action="register-exec.php">
<table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<th>First Name </th>
<td><input name="fname" type="text" class="textfield" id="fname" /></td>
</tr>
<tr>
<th>Last Name </th>
<td><input name="lname" type="text" class="textfield" id="lname" /></td>
</tr>
<tr>
<th width="124">Login</th>
<td width="168"><input name="login" type="text" class="textfield" id="login" /></td>
</tr>
<tr>
<th>Password</th>
<td><input name="password" type="password" class="textfield" id="password" /></td>
</tr>
<tr>
<th>Confirm Password </th>
<td><input name="cpassword" type="password" class="textfield" id="cpassword" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Register" /></td>
</tr>
</table>
</form>
</body>
</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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Registration Successful</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Registration Successful</h1>
<p><a href="login-form.php">Click here</a> to login to your account.</p>
</body>
</html>
<?php
include "header.php";
//All the Database connection from this file
include_once(intermediate.php);
//make sure we're using the right database
mysql_select_db("moviesite");
$query = "SELECT movie_name, movie_type " .
"FROM movie " .
"WHERE movie_year>1990 " .
"ORDER BY movie_type";
$results = mysql_query($query)
or die(mysql_error());
while($rows = mysql_fetch_array($results)) {
foreach ($rows as $val1) {
echo $val1;
echo " ";
}
//extract($rows);
//echo $movie_name;
//echo " - ";
//echo $movie_type;
echo "<br>";
}
include "footer.php";
//end of document
?>
<?php
include "header.php";
//connect to MySQL; note we’ve used our own parameters- you should use
//All the Database connection from this file
include_once(intermediate.php);
//make sure we're using the right database
mysql_select_db("moviesite");
//In this exercise, you’ll link the two tables with a JOIN.
$query = "SELECT movie_name, movietype_label " .
"FROM movie " .
"LEFT JOIN movietype " .
"ON movie_type = movietype_id " .
"WHERE movie.movie_year>1990 " .
"ORDER BY movie_type";
/* Order the table
"SELECT movie.movie_name, movietype.movietype_label " .
"FROM movie, movietype " .
"WHERE movie.movie_type = movietype.movietype_id " .
"AND movie.movie_year>1990 " .
"ORDER BY movie_type"; */
/*"SELECT * " .
"FROM movie " .
"WHERE movie_year>1990 " .
"ORDER BY movie_type"; */
$result = mysql_query($query)
or die(mysql_error());
echo "<table border=\"1\">\n";
while ($rows = mysql_fetch_assoc($result)) {
echo "<tr>\n";
//need to find out what this things are actually doing
foreach($rows as $value) {
echo "<td>\n";
echo $value;
echo "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
include "footer.php";
?>
<?php
/*
* untitled.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Sorting Files</title>
<meta content="content-http-php" />
<meta copyright="Itechereload Ltd" />
</head>
<body>
<?php
$flavor[] = "blue raspberry";
$flavor[] = "root beer";
$flavor[] = "pineapple";
sort($flavor);
print_r($flavor);
?>
</body>
</html>
�PNG

IHDR##��$ pHYs  ���IDATxڽ��n���:��2g�S�)�%ʶ����Ȃ��|�0��I� ?M $Ɂ�D�:�HJ��P�a�t�Y�r1&-�#�t�U_t�_u�合���«��$��ga�)�q E
�2��J�$R����Aܸ.������}�_��-�����ߘF3)��w���['�E�%�N)g�D |�鳻<��n�����"^^"{"D�����}e�dwC���g�P�<���ɱ����x���H��IV��Qԕ�n����wϧt���� ;�m�����5��f�2�8:ݻ����ı3�4�DA��K�=)�*���)m�Z�-E]��d_���b][RI�(=����#b�9��ǡx�|W�e\���N�ﻫW�Td��e�xc�(lMԪ�)��ʬi.G�%�L��BQJ�iDL|y��>[/;���6~O�"�&qs"���~��V^��/�$d�=s�����'����Ͳ���)^�t^'��2�έ�3+d���D�s���lgSz��7�=SWR�B��˩���n~��t����������v�wij� 6�8o�����@s�sӜ�L�@�qnD!2�E-�#��8yh�%M���`����7�^m�f���Ν�?��k��Ȭ׉���\z����V�z:qY�c$vǧ�SD��x�d��� Z)����v����Cp'첬���?�s J1iO� .(�D�����*LU��P��i��i]��j&ށ��\a�L�H�������nUkJ!�g�"[�k_ܩ�,`�ǡ� �������wu\W�D��N��5���e[��������y�޸�$��W���~r��|69�'��M]1��r4�n�گ��ܩf�l=��So; ��K�7�gQ���G�>��b�;�7��?|���Л��Ѓ�Ǯ��f~X��^�Z�v�5�װ���n&� a���r��������D�C�#�v�v�ч�l�~�,Bn�������2hD�L@:��V�`M�MUvA�ca'��l�c��[���;#q#_RIcd�x6&�!�
$PB�|��Gq E��K���!l� ��� �Gʼh�CY�[ * D��˶��]F.�C(E�C�Hd��g��!8!遥���HǾP����#hv^,���#�%@L��eWT�P pʾ&�87�|�|��ޑ��8X9��^��Sj��"�U?](��d�4.G� \Q����=�}�E�C\l�$Ȑ=y{C(H�,��j�fa�i<q)�YN&��J!��|��l�3k��l[�M���0������$� Ic)j.ƍ ��r\m@�Q"�>�ξ^�xc�{?ۺg(${���N��o�;K�����e*�qsAWj�4�O��uW�Jkw�u�k'.6_�1�x��}�'��J������p�;aWr�!���2r�}��y��H@�*����C�������Ww2���S��;o����8�IEND�B`�
body {
}
.footer
{
margin:auto;
width:70%;
background-color:#ffffff;
}
<?php
/**
** type navigation system. Hint: Use OFFSET to control which movie is on which page.
* * table1.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
**/
?>
<?php
include "header.php";
//All the Database connection from this file
include_once(intermediate.php);
/*Then make sure you are connecting to the ringht database*/
mysql_select_db('moviesite', $db)
or die(mysql_error($db));
//Know retrieve information from the database
$query = 'SELECT movie_name, movie_year, movie_director, movie_leadactor, movie_type
FROM movie
ORDER BY movie_name ASC, movie_year DESC';
$results = mysql_query($query, $db)
or die(mysql_error($db));
//testing query
//print($results);
//echo $results;
//Now check the number of rows that the variable $row
$num_movies = mysql_num_rows($results);
?>
<div style="text-align: center;">
<h2> Movie Review Database</h2>
<table border='1' cellpadding='2' cellspacing='2'
style="width: 70%; margin-left: auto; margin-right: auto;">
<tr>
<th>Movie Title</th>
<th>Year of Release</th>
<th>Movie Director</th>
<th>Movie Lead Actor</th>
<th>Movie Type</th>
</tr>
<?php
//Insert a while loop function here
while ($row = mysql_fetch_assoc($results)) {
extract($row);
echo '<tr>';
echo '<td>' . $movie_name . '</td>';
echo '<td>' . $movie_year . '</td>';
echo '<td>' . $movie_director . '</td>';
echo '<td>' . $movie_leadactor . '</td>';
echo '<td>' . $movie_type . '</td>';
echo '</tr>';
}
?>
</table>
<p><?php echo $num_movies; ?> Movies</p>
</div> <!-- Testing this document -->
<?php include "footer.php"; ?>
<!-- So far it works, lets expand this document -->
<?php
/**
** type navigation system. Hint: Use OFFSET to control which movie is on which page.
* * table2.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
**/
?>
<?php
include "header.php";
//take in the id of a director and return his/her full name
//uses a new way to connect to the database -by using functions
function get_director($director_id) {
global $db; //connect to the database and run the query
//Global connect to the database and allow the query to run
$query = 'SELECT
people_fullname
FROM
people
WHERE
people_id = ' . $director_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
//take in the id of a lead actor and return his/her full name
function get_leadactor($leadactor_id) {
global $db; //first connect the database
//now run the query
$query = 'SELECT
people_fullname
FROM
people
WHERE
people_id = ' . $leadactor_id; //to get peoples name where id
//is the same as leadactor_id
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
//take in id of movie type and return the meaningfull textual description
function get_movietype($type_id) {
global $db;
$query = 'SELECT
movietype_label
FROM
movietype
WHERE
movietype_id = ' . $type_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $movietype_label;
}
//All the Database connection from this file
include_once(intermediate.php);
/*Then make sure you are connecting to the ringht database*/
mysql_select_db('moviesite', $db) or die(mysql_error($db));
//Know retrieve information from the database
$query = 'SELECT movie_name, movie_year, movie_director, movie_leadactor, movie_type
FROM movie
ORDER BY movie_name ASC, movie_year DESC';
$result = mysql_query($query, $db)
or die(mysql_error($db));
//testing query
//print($results);
//echo $results;
//Now check the number of rows that the variable $row
$num_movies = mysql_num_rows($result);
//change this code from html to php
$table = <<<ENDHTML
<div style="text-align: center;">
<h2> Movie Review Database</h2>
<table border='1' cellpadding='2' cellspacing='2'
style="width: 70%; margin-left: auto; margin-right: auto;">
<tr>
<th>Movie Title</th>
<th>Year of Release</th>
<th>Movie Director</th>
<th>Movie Lead Actor</th>
<th>Movie Type</th>
</tr>
ENDHTML;
//<!-- //Insert a while loop function here -->
while ($row = mysql_fetch_assoc($result)) {
extract($row);
$director = get_director($movie_director);
$leadactor = get_leadactor($movie_leadactor);
$movietype = get_movietype($movie_type);
$table .= <<<ENDHTML
<tr>
<td>$movie_name</td>
<td>$movie_year</td>
<td>$director</td>
<td>$leadactor</td>
<td>$movietype</td>
</tr>
ENDHTML;
}
$table .= <<<ENDHTML
</table>
<p>$num_movies Movies</p>
</div> <!-- Testing this document -->
<!-- So far it works, lets expand this document -->
ENDHTML;
//Add one echo statement at end to be able to see output
echo $table;
include "footer.php";
?>
<?php
/**
** type navigation system. Hint: Use OFFSET to control which movie is on which page.
* * table2.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
**/
?>
<?php
//All the Database connection from this file
include_once(intermediate.php);
/*Then make sure you are connecting to the ringht database*/
mysql_select_db('moviesite', $db)
or die(mysql_error($db));
//Know retrieve information from the database
$query = 'SELECT movie_name, movie_year, movie_director, movie_leadactor, movie_type
FROM movie
ORDER BY movie_name ASC, movie_year DESC';
$results = mysql_query($query, $db)
or die(mysql_error($db));
//testing query
//print($results);
//echo $results;
//Now check the number of rows that the variable $row
$num_movies = mysql_num_rows($results);
?>
<div style="text-align: center;">
<h2> Movie Review Database</h2>
<table border='1' cellpadding='2' cellspacing='2'
style="width: 70%; margin-left: auto; margin-right: auto;">
<tr>
<th>Movie Title</th>
<th>Year of Release</th>
<th>Movie Director</th>
<th>Movie Lead Actor</th>
<th>Movie Type</th>
</tr>
<?php
//Insert a while loop function here
while ($row = mysql_fetch_assoc($results)) {
extract($row);
echo '<tr>';
echo '<td>' . $movie_name . '</td>';
echo '<td>' . $movie_year . '</td>';
echo '<td>' . $movie_director . '</td>';
echo '<td>' . $movie_leadactor . '</td>';
echo '<td>' . $movie_type . '</td>';
echo '</tr>';
}
?>
</table>
<p><?php echo $num_movies; ?> Movies</p>
</div> <!-- Testing this document -->
<!-- So far it works, lets expand this document -->
<?php
/**
** type navigation system. Hint: Use OFFSET to control which movie is on which page.
* * table2.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
**/
?>
<?php
include "header.php";
//Start session
session_start();
//Include database connection details
//All the Database connection from this file
include_once(intermediate.php);
//take in the id of a director and return his/her full name
//uses a new way to connect to the database -by using functions
function get_director($director_id) {
global $db; //connect to the database and run the query
//Global connect to the database and allow the query to run
$query = 'SELECT
people_fullname
FROM
people
WHERE
people_id = ' . $director_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
//take in the id of a lead actor and return his/her full name
function get_leadactor($leadactor_id) {
global $db; //first connect the database
//now run the query
$query = 'SELECT
people_fullname
FROM
people
WHERE
people_id = ' . $leadactor_id; //to get peoples name where id
//is the same as leadactor_id
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
//take in id of movie type and return the meaningfull textual description
function get_movietype($type_id) {
global $db;
$query = 'SELECT
movietype_label
FROM
movietype
WHERE
movietype_id = ' . $type_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $movietype_label;
}
/*connect to MySQL without showing the Database details by importing the details
** from another file holding all permition and user files*/
$db = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$db) {
die('Failed to connect to server: ' . mysql_error());
}
/*Then make sure you are connecting to the right database*/
//Select database
mysql_select_db(DB_DATABASE) or die(mysql_error($db));
//Know retrieve information from the database
$query = 'SELECT movie_id, movie_name, movie_year, movie_director, movie_leadactor, movie_type
FROM movie
ORDER BY movie_name ASC, movie_year DESC';
$result = mysql_query($query, $db)
or die(mysql_error($db));
//testing query
//print($results);
//echo $results;
//Now check the number of rows that the variable $row
$num_movies = mysql_num_rows($result);
//change this code from html to php
$table = <<<ENDHTML
<div style="text-align: center;">
<h2> Movie Review Database</h2>
<table border='1' cellpadding='2' cellspacing='2'
style="width: 70%; margin-left: auto; margin-right: auto;">
<tr>
<th>Movie Title</th>
<th>Year of Release</th>
<th>Movie Director</th>
<th>Movie Lead Actor</th>
<th>Movie Type</th>
</tr>
ENDHTML;
//<!-- //Insert a while loop function here -->
while ($row = mysql_fetch_assoc($result)) {
extract($row);
$director = get_director($movie_director);
$leadactor = get_leadactor($movie_leadactor);
$movietype = get_movietype($movie_type);
//Edit the heredoc to that generates the table rows
$table .= <<<ENDHTML
<tr>
<td><a href="movie_details.php?movie_id=$movie_id" title="Click here to find out more about $movie_name">$movie_name</a></td>
<!-- // comment this line out as the above line replaces it <td>$movie_name</td> -->
<!-- //You should notice a slight change between Figure //4-4 (table2.php) and Figure //4-5
//(table3.php). You now have links to more detailed information about //each movie for your
//visitor to click -->
<td>$movie_year</td>
<td>$director</td>
<td>$leadactor</td>
<td>$movietype</td>
</tr>
ENDHTML;
}
$table .= <<<ENDHTML
</table>
<p>$num_movies Movies</p>
</div> <!-- Testing this document -->
<!-- So far it works, lets //expand this document -->
ENDHTML;
//Add one echo statement at end to be able to see output
echo $table;
?>
<?php include "footer.php"; ?>
<?php
/*
* template.php
*
* Copyright 2012 Tdlm <tdlm@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Template PHP </title>
</head>
<body>
<?php
echo "This is PHP Template";
?>
</body>
</html>
<?php
/*
* untitled.php
*
* Copyright 2012 root <root@tdlm>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
include "header.php";
//Start session
session_start();
//Include database connection details
//require_once make shore that the function only runns once on the server!
require_once('config.php');
/*connect to MySQL without showing the Database details by importing the details
** from another file holding all permition and user files*/
$db = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$db) {
die('Failed to connect to server: ' . mysql_error());
}
/*Then make sure you are connecting to the right database*/
//Select database
mysql_select_db(DB_DATABASE) or die(mysql_error($db));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>untitled</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Bluefish 2.2.2" />
</head>
<body>
<?php
?>
</body>
</html>
@tdlmatias
Copy link
Author

This is PHP learning env

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment