... behind the core of PHP.
Why use PHP?
Put simply, when it comes to developing
dynamic Web sites, PHP is better, faster,
and easier to learn than the alternatives.
What you get with PHP is excellent ... Microsoft construct), JSP (Java
Server Pages) , ColdFusion, Ruby on Rails (a
Web development framework for the Ruby
programming language), and PHP. Dynamic
Web sites don’t always rely on a database, ...
PHP: Hypertext Preprocessor.”
According to the official PHPWeb site,
found at
www .php. net
A
, PHP is a
“widely used general-purpose scripting
language that is especially suited for Web...
... technology for creatingdynamicwebpages that only lets you use scripting
languages
q ASP.NET – a server-side technology for creatingdynamicwebpages that lets you use any fully-
fledged programming ... take a look at its role in helping to create
dynamic web pages.
How are DynamicWebPages Served?
To fully understand the nature of dynamicweb pages, we first need to look at the limitations ... and select Never dial a connection.
Chapter 1
8
q DynamicWebPages
q An overview of the different technologies for creatingdynamicweb pages, including ASP.NET
q Installing Internet Information...
... the World Wide Web.
Icon, like many other programming languages, has evolved over a period of
time. The first edition of this book described Version 5 of Icon, and the second edition
described ... understanding of the concepts
of computer programming languages and a familiarity with the current terminol-
ogy in the field. Programming experience with other programming languages, such
as Pascal ... changes the length
of s, the result can be confusing.
THE ICON
PROGRAMMING
LANGUAGE
Ralph E. Griswold • Madge T. Griswold
Third
Edition
Characters, Csets, and Strings Chap. 4
60
CSETS
Cset Literals
A...
... by
an ever—growing collection of programming languages and programming
frameworks—all erected on an ever-expanding platform of interpreters.
Do you want to create Web pages? In 1990, that meant formatting ... formatting static
text and graphics, in effect, creating a program to be run by browsers exe-
cuting only a single “print” statement. Today’s dynamicWebpages make
full use of scripting languages ... draft of the
second edition, assumed the onerous task of suggesting a difficulty level for
each exercise for that edition. Chung-chieh Shan taught from an early draft
of the third edition and provided...
... solid
foundation.
12
Practical PHP and MySQL
$pages = $stories / $pagesize;
echo "Rounded down: " . floor( $pages)
. " Rounded up: " . ceil( $pages) ;
?>
To use these handy ... develop
and now forms the comprehensive PHP platform we know today.
PHP provides a solid and well-defined programming language that includes
support for object-orientated programming, conditions, file ... database.
In addition to PHP s capability as a Web scripting language, PHP also can be
used as a shell scripting language. This means that you can use a single language to
write Web applications and...
... feel.
70
Practical PHP and MySQL
Creating the Header File
Create a file called header .php and add the code shown in Example 4-2.
EXAMPLE 4-2 This simple header file will be used across all pages.
< ?php
require("config .php& quot;);
?>
<!DOCTYPE ... work by creating a file called
index .php and adding the code in Example 4-4.
EXAMPLE 4-4 With a header and footer, actual site pages become very simple.
< ?php
require("header .php& quot;);
require("footer .php& quot;);
?>
Iterating ... you will make use of phpMyAdmin, a tool included with XAMPP, to create the
database.
First, open your Web browser and connect to phpMyAdmin by accessing
http://localhost/phpmyadmin/. A login...
... header .php. In login .php and logout .php, you added ses-
sion_start()
at the beginning of the page. You will use session_start() in most of
your pages, so add it to the top of header .php:
< ?php
session_start();
This ... viewcat .php page to view the newly created
category.
Finally, close the
else and include the footer .php file (all after the form):
< ?php
}
require("footer .php& quot;);
?>
CREATING ... Create a file called
index .php and start by including header .php:
< ?php
require("header .php& quot;);
Run a query to get all of the categories:
require("header .php& quot;);
$catsql = "SELECT...
... footer:
</table>
</form>
< ?php
}
require("footer .php& quot;);
?>
CREATING ADMINISTRATOR-SPECIFIC PAGES
With the user-accessible pages complete, you can now create the administrator-
specific pages. These pages ... addforum .php) , cat (redirects to
addcat .php) , and
del (redirects to delete .php) .
With the ability for an administrator to log in, add the administrator links above
the table on index .php:
< ?php
require("header .php& quot;);
if(isset($_SESSION['ADMIN']) ... bestorangejuice.jpg.
Create a new file called products .php and start to add the code:
< ?php
require("db .php& quot;);
require("functions .php& quot;);
$validid = pf_validate_number($_GET['id'],
"redirect",...
... “</p>”;
228
Practical PHP and MySQL
Create a file called index .php and add the following code:
< ?php
require(“config .php );
require(“functions .php );
One of the planned features for index .php is to list ... Site
Create a new file called itemdetails .php and add the usual introductory code:
< ?php
session_start();
include(“config .php );
include(“functions .php );
$db = mysql_connect($dbhost, $dbuser, ... id=”menu”>
<a href=”index .php >Home</a>
< ?php
if(isset($_SESSION[‘USERNAME’]) == TRUE) {
echo “<a href=’logout .php >Logout</a>”;
}
else {
echo “<a href=’login .php >Login</a>”;
}
?>
<a...
... . $config_basedir . “/addimages .php? id=” .
$itemid);
}
else {
header(“Location: “ . $config_basedir .
“/newitem .php? error=date”);
}
}
277
CHAPTER 8 Creating a Web- Based Calendar
FIGURE 8-2 Because ... button.
287
CHAPTER 8 Creating a Web- Based Calendar
After you have protected the page from any users not logged in, create a small
function:
< ?php
session_start();
require("config .php& quot;);
if(isset($_SESSION['LOGGEDIN']) ... out
regularly or on reboot.
Configure this directory inside php. ini by setting the
upload_tmp_dir option
in php. ini.
265
Creating a Web- Based
Calendar
CHAPTER 8
For most of us, life is increasingly...
... project.
Create a new file called addquestion .php and add the following code:
< ?php
session_start();
require("db .php& quot;);
require("functions .php& quot;);
Only logged-in users should ... file called login .php and add the code
shown in Example 9-4.
EXAMPLE 9-4 This code is virtually the same as previous login pages.
< ?php
session_start();
require("config .php& quot;);
if($_SESSION['SESS_USERNAME']) ... $config_basedir
. "userhome .php& quot;);
}
else {
header("Location: " . $config_basedir
. "/login .php? error=1");
}
}
else {
require("header .php& quot;);
if($_GET['error'])...
... file
called functions .php and add the configuration file:
< ?php
require("phphomeprojectconfig .php& quot;);
Add pf_protect_nonadmin_page():
require("phphomeprojectconfig .php& quot;);
function ... subject is deleted.
Create deletesubject .php and add the following code:
< ?php
session_start();
require("db .php& quot;);
require("functions .php& quot;);
if($_SESSION['SESS_ADMIN']) ... "details":
require("header .php& quot;);
388
Practical PHP and MySQL
Accessing the Database
In the base directory (phphomeproject), create db .php and add the connection code
shown in...
... involves creating a fairly common form that takes in information and
puts it in the database. Create addstory .php and begin including your files:
< ?php
session_start();
require("config .php& quot;);
require("functions .php& quot;);
require("db .php& quot;);
In ... files:
< ?php
session_start();
require("config .php& quot;);
require("functions .php& quot;);
require("db .php& quot;);
In addition to the usual include files, include HTML_QuickForm:
require("db .php& quot;);
require_once 'HTML/QuickForm .php& apos;;
When ... 443
CHAPTER 11 Building a News Web Site
</tr>
</table>
</form>
< ?php
}
require("footer .php& quot;);
?>
Logging Out Users
To log out a user,...