Graphics Programs Reference
In-Depth Information
Problem Solving: Copying and Pasting Code
As you use more advanced techniques, you will begin to work with code more frequently.
When you want the same functionality in two different places, a good technique is to copy
the code from one location and paste it in the other location. Not only does this technique
save you time, it also eliminates the chance of mistyping the code. It is also an acceptable
technique to copy and paste code from other code sources that are “available to the
public” such as sample code sites and topics that teach coding techniques. When copying
and pasting code from one source to another, paste the copied code into a style-free
text editor such as TextPad or Notepad and remove any formatting from the text before
pasting it into the code of your Web pages. This prevents hard-to-trace code errors that
arise from pasting formatted text in code.
Creating a Login Page to Protect Back-End Pages
Data collected from a Web site and stored in a database is often displayed in Web pages.
This convenience enables you to view the data from any computer that is connected to
the Internet. However, most businesses do not want the general public to have access
to this type of proprietary information. One way to restrict the access to Web pages is to
require users to log in before they can view the pages. This protects the data from unau-
thorized access. To add this functionality, you must:
Create a table in the database that holds usernames and passwords. The team that
created the SQL you used to create the database included an administrative table with
columns to collect usernames and passwords. They also added one username (next-
best) and one password (watchthetapes) in the table. You will use the username and
password included in the database to create and test the login.php page.
Create a page that enables users to create accounts by entering a unique username
and password. Because only one member of the NextBest Fest staff is in charge of
monitoring and reporting the information collected in the database, you won't create
this page now. The team member will use the supplied username and password to log
in to protected pages. At another point, the team will create additional pages to enable
users to create unique usernames and passwords.
Create a page that enables users to log in to the site. You have already created the
login.php page. Now you will create a form in the login.php page that allows users
to input their username and password information. You will add the Log In User
server behavior to the page, which will check the database when a user submits the
form to ensure that the username and password are valid. If login is successful, the
database.php page will appear in the user's browser window. If login is unsuccessful,
the access_denied.html page will be displayed in the browser window.
Restrict access to the pages. You add the Restrict Access To Page server behavior to the
pages that you want to protect, in this case, the database.php and database_details.php
pages. After this behavior is added to the pages, users who are not logged in will be
sent to the access_denied.html page.
You'll create the form in the login.php page, and then add the Log In User server
behavior to the page.
Search WWH ::




Custom Search