Web Design

(Nancy Kaufman) #1

303


CHAPTER

Adding Information from a Database 13


TIP


Because this file contains my username and password, how can I keep it safe?
Once you have opened it in your Web browser to ensure that it works correctly, you should move it outside
of your Web server’s root folder. Many developers simply store it in the directory above the Web root. The
Web server does not have access to files outside of its root, so a potential hacker cannot access it via a Web
browser. PHP, on the other hand, can still access files outside of the root with its include function, so
placing the file there limits access to it to your PHP application.

7 Open your Web browser and
type http://
localhost/?, replacing?
with the name
of the file from Step 6.
● The page loads in the
browser and is blank if no
errors occur. If an error
appears, recheck your code.


4 Type mysqlselect
db(‘?’);, replacing? with
the name of the database
you created on your server.


5 Type ?>.


6 Save the file in the Web
server’s root directory.


4


5


7

Free download pdf