Writing a tips of the day program

By using the readFile( ) command, which is a PHP function you can create a tip of the day program. To begin this program, we use basic HTML, along with CSS - Cascading Style Sheets and a line of PHP code. The PHP code uses the <? and ?> special tag and the readFile( ) command is placed inside with a filename, such as "tips.txt" as shown below, that is read and is displayed on your web page. As we demonstrated in the first program, we used notepad a plain text editor and stored the program on our web server, "C:\Wampserver2\www."

The steps to writing a PHP program are outlined below:

1. Select and click "Start."
2. Select and click "All Programs."
3. Select and click "Accessories."
4. Select and click "Notepad."
5. Type the HTML, CSS and PHP exactly as shown below.

<html>

<head>

<title>Tip of the Day</title>

</head>

<body>

<center>

<h1>Tip of the Day</h1>

<div style = "border-color:green; border-style:groove; border-width:2px">

<?php

readfile("tips.txt");

?>

</div>

</center>

</body>

</html>

6. Once you have type the entire program, Select "File," "Save As," and then go to the webroot of your server. For example, C:\Wampserver2\www. Type Filename, "tips.php," and then Select "Save."

The steps to creating a Text file to be read within the PHP program are outlined below:

1. Select and click "Start."
2. Select and click "All Programs."
3. Select and click "Accessories."
4. Select and click "Notepad."
5. Type the text exactly as shown below.

hey there, how are you?

6. Once you have typed the text, Select "File," "Save As," and then go to the webroot of your server. For example, C:\Wampserver2\www. Type Filename, "tips.txt," and then Select "Save

7. Use your browser to view the tips.php program. The steps are outlined below:

  1. Select and click "Start. "
  2. Select and click "All Programs."
  3. Select and click "Internet Explorer."
  4. Locate the Web Address Field, near the top-left of the Internet Explorer window and type in the Web address of the tips.php program, "http://localhost/tips.php," then enter. The tips.php program will be displayed.
Advertisement

, Tampa Information Technology Examiner

Ginny Putscher, a 25-year information technology veteran, has worked with both private industry and federal government. Ginny's experiences include traveling and working in many foreign countries - Egypt, El Salvador, Kenya, Tanzania and Senegal. Ginny received her BA in Database Development...

Today's top buzz...