Created
March 25, 2015 01:01
-
-
Save tdlmatias/358fbcb79ac20a6fb188 to your computer and use it in GitHub Desktop.
This testing PHP learning env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHP-Developer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="CopyrightManager"> | |
<settings default="" /> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="DependencyValidationManager"> | |
<state> | |
<option name="SKIP_IMPORT_STATEMENTS" value="false" /> | |
</state> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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"> </p> | |
<h4 align="center" class="err">Access Denied!<br /> | |
You do not have access to this resource.</h4> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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!"; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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!'; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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 contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This file is created to control the access file-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 */ | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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"> </p> | |
<h4 align="center" class="err">Login Failed!<br /> | |
Please check your username and password</h4> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> </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> </td> | |
<td><input type="submit" name="Submit" value="Login" /></td> | |
</tr> | |
</table> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"> </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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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!"; | |
?> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PK 3Z9 | |