Using PHP in pages with the html extension. Form in your layout How to read html page php

I'm trying to create a login form. This is my HTML form code

Personally, I got it for PDO.

Points 4 and 5

$password = mysql_real_escape_string(stripslashes(md5($_POST["password"])));

First, the order of this is wrong. You hash $_POST["password"] and then trying to use stripslashes - after its hashes will not have any slashes. However, if you're trying to prevent people from using slashes (or anything else) in passwords, you'll need to remove them before hashing the string.

The following md5 should not be used as a password hashing algorithm, which has been found to be weak and can be brute force to create string collisions much more often than necessary.

Yes you must store hashes or "fingerprints" of passwords, not the passwords themselves, but ideally you want to salt and hash (with at least sha1) those passwords, rather than just throwing them into the md5() function.

And search for "password hash setting" using your search engine of choice.

Point 6

SELECT id FROM $table WHERE username = "" . $username. "" and password = "" . $password. "";

I added in = which was missing from the original question, but that's it did not match the username and password in your request...if someone managed to get an SQL injection into your username, the password will never be verified. Introduce:

SELECT user.id FROM user WHERE user.username = "fred" OR 1 = 1 -- AND user.password = "abc123"

It is better to select the fingerprint user ID and password from the database and then evaluate the password in the application rather than trusting the database level password verification. This also means that you can use a special hashing and salting algorithm within the app itself to verify your passwords.

Point 7

$_SESSION["user"] = $_POST["username"];

Is it just storing the username in the session? This should not be used as a "login verifier" in any way, especially if there is (apparently) nothing on your session to prevent hijacking.

The session ID can be easily sniffed from the cookie in real time, and that's all that would be required to "borrow" someone else's username. You should at least try to reduce the likelihood of session hijacking by associating the user's IP address, UserAgent string, or some other combination of relatively static data that can be compared to each page... there are disadvantages to almost any approach though (especially, as I've already found, if you have visitors using AOL), but you can make a possible 99% effective fingerprint session possible to reduce hijacking with a very small chance that the user's session will be mistakenly reset.

Ideally you could also create a session token to mitigate CSRF attacks when the user needs to perform a "privileged" action on the database (update their data or something else). The token can be a completely random and unique code stored in a database and/or cookie SSL when the user logs in (provided that the user cannot perform any actions that update the database outside of HTTPS, as this will simply transmit the data in clear text over the Internet - which would be bad idea).

The token is placed in a hidden form field for any/all forms and is checked against the value stored in the cookie (or session or database) when that form is submitted. This ensures that the person submitting the form will have a live session on your website at the very least.

There could be several problems.

Firstly, in your $match statement you are missing the password equality operator:

$match = "SELECT id FROM $table WHERE username = "".$username."" and password"".$password."";";

Should be:

$match = "SELECT id FROM $table WHERE username = "".$username."" and password = "".$password."";";

Secondly, you insert the password into the database after its use using md5?

If not, then your request is trying to match the md5 (password) with the password.

When creating even a personal website, not everyone can provide for everything possible ways its further use. It is very important to prepare the ground for further development of the site. If you've created a website in the past and assigned the .html extension to all pages by default, and only then decided to use PHP, then read on.

Previously, to use SSI, site page names had to end with the .shtml extension, but today most Internet servers are configured so that SSI can be used on pages with the .html extension, which is quite convenient. PHP is a completely different story - the .php extension is the default extension. Website developers knowing in advance what will be used given language programming, the rhinestone is assigned the correct extension.

But what to do when all pages end with the .html extension?

Replace HTML extension with PHP

This can be done in several ways. The most obvious way is to give all pages a .php extension or change existing extensions (.html, .shtml, etc.). This method has disadvantages. For example, already indexed pages with the .html extension will have to be indexed again search engines. Or even worse - everything external links, which explicitly link to a particular page will be invalid. And you will have to notify the owners of each site about these changes and create another page with 301 errors for each page. Of course, changing one extension to another is acceptable, but what if the site already has many pages and many links to different pages from other sites?

For a conscious reason this moment all pages of this site end with the html extension, and I did not want to make the above changes, thereby creating unnecessary difficulties for myself.

You can do it another way. If the server hosting the site supports mod_rewrite (in most cases it does), and there is access to the .htaccess file, then you can add the following lines to this very file:

RewriteEngine on RewriteRule ^(.*)\.html $1\.php

By adding this code to .htaccess , you don't have to worry. All requested non-existent pages with a .html extension will be automatically replaced with a .php extension thanks to the wonders of Apache. But this method is not the only one. You can write the following in the same .htaccess file:

AddHandler application/x-httpd-php .php .html .htm

In my opinion the most successful way. This makes HTML pages equal to PHP pages, meaning all PHP functions can now be used in pages with an HTML extension. If you don’t have access to the .htaccess file, then you can write a letter to the hosting company and politely ask the admins to register in Apache configurations(httpd.conf) the required value for the site.

By the way, if before this the site used SSI as follows:

then in the new PHP state this code needs to be replaced with:

Well, that’s all, I think one of the above methods will help.

PHP is an embedded server-side programming language. Much of its syntax is borrowed from C, Java, and Perl. And also added a couple of unique characteristics only for PHP functions. The main purpose of this language is to create dynamically generated PHP HTML pages.

PHP to HTML

When creating complex web pages, you will be faced with the need to combine PHP and HTML to accomplish specific tasks. At first glance, this may seem complicated, since PHP and HTML are two independent disciplines, but this is not so. PHP is designed to interact with HTML, and its code can be included in page markup.

PHP code is included in HTML pages using special tags. When a user opens a page, the server processes the PHP code and then sends the result of the processing (not the PHP code) to the browser.

HTML and PHP are quite easy to combine. Any part of a PHP script outside of tagsis ignored by the PHP compiler and passed directly to the browser. If you look at the example below, you can see that a complete PHP script might look like this:

Hello today.

The above code is plain HTML with a little PHP snippet which outputs current date using the built-in date function. In this case, all HTML will be ignored by the PHP compiler and transmitted to the browser unchanged.

Integrating PHP into HTML is really very easy. Remember that a script is an HTML page with some PHP code included. You can create a script that will contain only HTML (no tags), and it will work fine.

More advanced methods:

  • Menu Item

and the result:

PHP to HTML using short_open_tag

If you need to make your code as short as possible before inserting HTML into PHP, you can use short_tags. As a result, you will not need to entershort_tags" With " Off" on " On". Although most servers already have this option enabled, it is always best to check this manually. A problem that can arise when using short tags is a conflict when using XML. In XML syntax expression

PHP to HTML using short__tag

Hello, today is.

Keep in mind that if you want to create a site that is compatible with as many platforms as possible, you shouldn't rely on short_tags when inserting PHP into HTML.

HTML to PHP using echo

Another way to integrate HTML into a PHP file is the echo: command.

This will affect markup highlighting in most editors. Therefore, it is necessary to select everything double quotes inside HTML code using a backslash.

PHP to HTML - File Extensions

For a standard configured web server:

AddHandler cgi-script .html .htm

For a web server running FastCGI:

AddHandler fcgid-script .html .htm

HTML to PHP

You can also use HTML code in PHP scripts. All you need to do is when opening a page using PHP, change the order of the pages that open HTML tags and PHP.

Using HTML in PHP:

Personal INFO

First Name:
Last Name:
"; ?>

Inserting PHP into HTML this way allows you to use much less code. Here we use $PHP_SELF globally, which allows the field values ​​specified below them to be used in the same file. Typically, two files are created for such forms: the first is the HTML form itself, and the second is the PHP file that performs the processing.

If you already have complex PHP applications that use a large number of files and want to simplify, this method can help.

This publication is a translation of the article “PHP in HTML”, prepared by the friendly project team

>

Php for beginners

On this page we will try to explain the logic of building a dynamic website. Php is a server-executed script. What does this mean? The server has a special interpreter installed that understands certain language constructs. The php file itself, it reads it line by line, as if running through it from top to bottom. If it finds, for example, the word exit, then it stops and doesn’t read anything further, but executes what it found before this word, for example print"Great!" Will print Great!

print"Great!";
exit ;
?>

This is the simplest php file, but in fact, in practice you have to deal with a complex php file. There are a lot of pages on the site, we currently have 24 thousand, we would have to write the same number of php files, or just html files. But, php allows you to do all this in one executable file. That is, we need to organize links in this file itself like, if this - do that, if that - do that. Php allows you to organize links very well. The general scheme is:

You see in the script that compartments like
if (then)
then we do it
}

Then what happened if the first condition was fulfilled, that is $uslovie 1== "yes", then we execute the script in brackets ( ) that relate to this section of the script, then in this section there is exit- here the program ends. That is, with the help of compartments we can split a php file into its component parts. And what is the condition - if($uslovie == "yes")??? This network is the same link, in this case, something will be executed if the variable $uslovie will be equal yes.

Let's name the file all.php. To organize links to it on the command line, simply add all.php?uslovie=yes. If you see a question mark on the command line, then this is the link in this case, $uslovie == "yes". Then we will create an html file in which we will write links to our executable script.



New Page


uslovie1=yes" >First link
uslovie2=yes" >Second link

You see two links. If you click on the links, the file will be executed all.php, and in the first case the script will be told that the variable $uslovie 1==yes, and in the second case, $uslovie 2==yes. From the first link the first compartment will be completed and the program will stop, using the second link the program will run through the first compartment and something from the second compartment will be fulfilled(see above). Please note that the dollar sign is not written in the links; the program makes them variables when passing them to the script, that is, when passing them to the command line.

Now we know how to organize links to a php file, how to divide it into sections and how to organize links in html text to our file. But, there is one more thing... The fact is that if you organize the site in this way, then in its original form, when there are not very many links, you will not see problems. Let's say there are 10 compartments, they will all fit quietly into one file. But if there are a lot of links, for example we have 24,000 pages, then in principle it is impossible to fit all the sections into one php file. You yourself will be tortured by searching for this or that compartment in one file for, for example, changing it. In addition, the file will be very large in size, our all.php would take up 1MB. In addition, you need to understand one more thing: on many servers there is a limit on the size of executable files (for example, 50Kb); if it is exceeded, such a file is ignored and not executed. In connection with these calculations, we reduced the size of the main file to 8Kb, although it carries a 1MB execution load. How to do this? Php provides an excellent opportunity to split a php file into pieces using the command included....

Now it becomes clear how we reduced our main file to 8Kb, because all other included files have a total size of 1 MB, and we hid them in a separate folder and connect them as needed, that is, depending on the links in the command line. The include command connects files as if they were written in the main script, therefore, if in the inserted files you will access databases or html files, then the counting will need to be carried out precisely from the main file, in our case all.php. For example, there is a folder html, it contains a file one.htm how to print it. Then the one.php file looks like this:

include"html/one.htm";
print
exit ;
?>

We have printed the contents one.htm, plus printed This is the first section of the program, and stopped the program. That is, based on html theory, we would have to include the file one.htm So: include "../html/one.htm", since the folder html lies one level above the file one.php. But in php this is not the case, the include command simply adds code to the script and it becomes an integral part of it, which means that all links are counted relative to the main file, and not the included ones.



New Page


uslovie1=yes" >Just First link
uslovie1=yes& act=yes" >
uslovie2=yes" >Just Second link
uslovie2=yes& act=yes" >Second link, but also act=yes

Then php file one.php transform it into this:

if($act == "yes")(
include"html/one.htm";
exit ;
}
print"This is the first section of the program";
exit ;
?>

If you clicked on the link uslovie1=yes" >Simply First link, will be printed This is the first section of the program, if you clicked on the link uslovie1=yes& act=yes" >The first link, but also act=yes, then the contents of the file will be printed html/one.htm, and the program will stop.

403 KB

Download the archive, it’s made in such a way that you don’t need to know Php, you only need to know HTML.

Yeah.))

It would be easier for me to make a copy of index.php and rename it, for example, to contact.php and then change middle to middle2 with new content.

Kettle I'm a little php


I still don't understand.
I have a website.
index file in the root. In another folder there are files top middle buttom for example.

There is a menu. I want a different middle to be shown when you click on a menu item.

How to do this, and where to put it???

Answer: Well, wherever. It’s very simple, it’s about making a menu script menus.html


something without an array $_GET ["uslovie"] ; your examples don't work for me

Answer: support for global variables is disabled on your server, if so, then you can put the line at the beginning of all your scripts

if (isset($_GET )) ( foreach($_GET as $key =>$val ) ( $$key =$val ; ) )

then you can use our scripts without using $_GET [ "uslovie" ] , but just put $uslovie


Quite an interesting resource you have..
Thanks for the info.

Answer:


You have long promised to look into how a PHP website is created. Why didn’t you keep your promise? Maybe write an article on this topic (and if you also use MySQL, then everything will be fine).

Answer:


Very yes. Only, there it is, instead of too.htm you probably need two.htm
Not essential, but to keep things in order))

Answer:


Tell me where I can read and learn by heart all the operators and PHP codes, for example: echo , include , else , if , print , foreach , isset etc., what do they mean and what do they serve?

Answer: Alexander, I was on vacation for a month, plus I’m currently completing a new version of the entire site. As soon as I finish, I will make a small page about this.


Mobilesfinks, while I was getting ready to reinstall php 4, a new version of the site in php 5 had already been released. And there were no problems, everything worked %tashus%

Answer:


Hello!

Please tell me how to make the TITLE at the top of the window change on each page: that is, " New Page" ...

For example, if you follow the link "1", then the window should be called "First section. Mathematics" - that is, the HTML code should be First section. Mathematics...
And if the link is “2”, for example, then the window should be called “Second Section. Geography” - that is, the HTML code should be Second section. Geography...

How can I make it change using PHP?

Answer: html.html


We need to install PHP4 for Denver. The installation script will make all the changes itself.
Then in the folder where you have the all.php file you create
a file called ".htaccess" and add a line to it
Page: 1
Current page: 1 Total messages: 22

Many readers in any book about computers skim over everything that is not of immediate interest and move on to what they really need. want know. Personally, that's what I do. However, there is nothing wrong with that - there are rarely technical books that need to be read from cover to cover. Or maybe that's what you did - skipped the initial eight chapters and picked up this chapter because it had the most interesting title? And who wants to waste time on details when another project is on fire at work?

Fortunately, such haste will not prevent you from properly mastering the material in the second part of the book, which is devoted to using PHP to build sites and interact with the Web. In this chapter, you will learn how to easily modify the content of web pages and navigate the Web using links and various standard functions. The next chapter will complement the material presented - it examines in detail the means of interaction with the user in HTML forms. Chapter 11 describes the organization of the interface with databases. The remaining chapters of the second part discuss non-trivial aspects of web programming in PHP.

However, it should be remembered that the material in Part 1 absolutely necessary for normal knowledge of PHP. It is assumed that you have already read Part 1, so the examples will use many of the concepts described earlier. So, if you skim through part of the book, you will have to go back to previous chapters from time to time and catch up.

Simple links

<а href = "date.php">

$link = "date.php";

print "<а href = \"$link\">View today's date
\n"

You are probably wondering why there is a backslash (\) before the quotes (") in the link code? The fact is that quotes in PHP are special characters and are used as line delimiters. Therefore, quotes are literals in strings must be shielded.

If having to escape quotes annoys you, simply enable the magic_quotes_gpc mode in your php.ini file. The result is all apostrophes, quotes, backslashes and null characters. are automatically escaped in the text!

Let's develop the given example. To quickly display a list of links in the browser, you can use an array:

// Create an array of sections

$contents - array("tutorials", "articles", "scripts", "contact");

// Iterate through and sequentially display each element of the array

for ($i = 0; $i< sizeof($contents; $i++)

print " ".$contents[$i]."
\n";

// - special designation for marker point endfor;

File components (templates)

We've come to one of my favorite PHP features. A template (in relation to web programming) is a part of a web document that you are going to use in several pages. Templates, like PHP functions, save you from unnecessary copying/pasting of page content and program code. As the scale of the site increases, the importance of templates increases, since they allow easy and quick modifications at the level of the entire site. This section will describe some of the possibilities that open up when using simple templates.

Typically, common pieces of content/code (i.e. templates) are saved in separate files. When building a web document, you simply “include” these files in the appropriate places on the page. In PHP there are two functions for this: include() and require().

include() and require()

One of the most outstanding aspects of PHP is the ability to build templates and programming libraries and then insert them into new scripts. Using libraries saves time and effort in using common functionality across different websites. Readers with

experience programming in other languages ​​(such as C, C++ or Java), and are familiar with the concept of function libraries and their use in programs to extend functionality.

Including one or more files in a script is done using the standard PHP functions require() and include(). As will be shown in the next section, each of these functions applies in a specific situation.

Functions

There are four functions in PHP for including files in PHP scripts:

  • include();
  • include_once();
  • require();
  • require_once().

Despite the similarity of names, these functions solve different problems.

The include() function includes the contents of a file into the script. The include() function syntax is:

include(file file]

The include() function has one interesting feature - it can be executed conditionally. For example, if a function call is included in an if command block. then the file is included in the program only if the condition i f is true. If the includeO function is used in a conditional command, then it must be enclosed in curly braces or alternative delimiters. Compare the differences in syntax between Listings 9.1 and 9.2.

Listing 9.1. Incorrect use of include()

if (some_conditional)

include("text91a.txt"); else

include("text91b.txt");

Listing 9.2. Correct use of include()

if (some_conditional) :

include("text91a.txt");

include("text91b.txt");

All PHP code in the include file Necessarily lies in PHP tags. Don't assume that simply saving a PHP command in a file will ensure it is processed correctly:

Instead, you need to wrap the command in appropriate tags, as the following example shows:

print "this is an invalid include file";

The include_once() function does the same thing as include(), with one exception: before including a file in the program, it checks to see if it has already been included. If the file has already been included, the include_once() call is ignored, and if not, the standard file inclusion occurs. In all other respects, include_once() is no different from include(). The include_once() function syntax is:

include_once(file file)

In general, the require() function is similar to include() - it also includes the template in the file in which the require() call is located. The require() function syntax is:

require (file file)

However, there is one important difference between the require() and include() functions. The file specified by require() is included in the script regardless of the location of require() in the script. For example, if you call requi re() in an if block, if the condition is false, the file will still be included in the script!

In many situations, it is convenient to create a file with variables and other information that is used throughout the site, and then include it as needed. Although the name of this file is arbitrary, I usually call it init.tpl (short for "initializaion.template"). Listing 9.3 shows what a very simple init.tpl file looks like. In Listing 9.4, the contents of init.tpl are included in the script with require().

Listing 9.3. Example of an initialization file

$site_title = "PHP Recipes";!}

$contact_email = " [email protected]";

$contact_name = "WJ Gilmore";

Listing 9.4. Using the init.tpl file

<? print $site_title; ?>

\"mai1 to:$contact_email\">$contact_name."; ?>

Passing a URL when calling require() is only allowed if the “URL fopen wrappers” mode is enabled (this mode is enabled by default).

As the size of the site increases, it may turn out that some files are included in the script several times. Sometimes this doesn't cause a problem, but in some cases, including the file again causes the values ​​of the changed variables to be reset. If the include file defines functions, naming conflicts may occur. With that said, we come to the next function - require_once().

The require_once() function ensures that the file is included in the script only once. Once requi re_once() is called, all further attempts to include the same file are ignored. The syntax of the require_once() function is:

You'll likely start using file inclusion features more often as your web applications begin to grow in size. These functions appear frequently in examples in this book to reduce code redundancy. The first examples are discussed in the next section on the principles of constructing basic templates.

Building Components

When defining the structure of a typical web page, I usually break it down into three parts: header, body, and footer. As a rule, most properly organized websites have a header that remains virtually unchanged; the main part displays the requested content of the site, so it changes frequently; Finally, the footer contains copyright information and navigation links. The footer, like the header, usually remains unchanged. Don't get me wrong - I'm not trying to suppress your creative aspirations. I've seen many great websites that don't follow these principles. I'm just trying to come up with a general structure that can serve as a starting point for further work.

Heading

A header file (like the one in Listing 9.5) appears in almost every one of my PHP-enabled websites. This file contains

site-wide information, such as the title, contact information, and some HTML page code components.

Listing 9.5. Example header file

// File: header.tpl

// Purpose: header file for the PhpRecipes website.

$site_name = "PHPRecipes";

$site_email= " [email protected]";

$site_path = "http://localhost/phprecipes";

<? print $site_name; ?>

// Print current date and time

print date("F d, h:i a");

Quite often, access to included files by visitors is restricted, especially if these files contain sensitive information (for example, passwords). In Apache, you can prevent certain files from being viewed by editing the http.conf or htaccess files. The following example shows how to prevent viewing of all files with a .tpl extension:

Order allow,deny

Allow from 127.0.0.1

PHP and website security issues are covered in detail in Chapter 16.

Running title

The footer is usually the information located at the bottom of the pages of a site - contact information, links and copyright information. This information can be placed in a separate file and included as a template in the same way as a header. Let's say that with the onset of the new year you need to change the copyright information and bring it to the form “Copyright © 2000-2001”. There are two options: Spend Christmas Eve frantically editing hundreds of static pages. or use a template like the one shown in Listing 9.6. One simple change and you can get back to your holiday routine.

Listing 9.6. Example footer file (footer.tpl)

contact |

your privacy

Note the use of the $site_email global variable in the footer file. The value of this variable is page-wide, and we assume that the header.tpl and footer.tpl files will be included in one final page. Also notice the presence of $site_path in the Privacy link. I always include the full path to all links in my templates - if the link URL were just privacy.php, the footer file would be hardcoded to a specific directory.

Main part

The main part of the page includes the contents of the header and footer. In essence, it is the main part that contains the information that interests site visitors. The header looks impressive, the footer contains useful information, but it is for the main part of the page that users return to the site again and again. Although I can't provide any advice on specific page structure, templates like the one in Listing 9.7 greatly simplify page administration.

Listing 9.7. Example of the main part of the page (index_body.tpl)

/tutorials.php">tutorials

articles

scripts

contact

Welcome to PHPRecipes. the starting place for PHP scripts, tutorials,

and information about gourmet cooking!

All together: header, footer and body

Perhaps my mood is best summed up by a line from Colonel “Hannibal” Smith (George Peppard) from the famous TV series “The A-Team”: “I love it when things fall into place.” I'm experiencing something similar where disparate templates come together to form a complete web document. By combining three document sections: header.tpl, index_body.tpl, and footer.tpl, you can quickly build a simple page like the one shown in Listing 9.8.

Listing 9.8. Building an index.php page by including several files

// File: index.php

// Destination: PHPRecipes home page

// Print title

include("header.tpl");

// Output the main part

include("index_body.tpl");

// Display the footer

include("footer.tpl");

So how? Three simple commands and you have a finished page. The text of the final page is shown in Listing 9.9.

Listing 9.9. HTML page built in Listing 9.8 (index.php)

PHPRecipes

August 23, 03:17 pm

tutorials

articles

scripts

contact

Welcome to PHPRecipes, the starting place for PHP scripts, tutorials,

and gourmet cooking tips and recipes!

Copyright 2000 PHPRecipes. All rights reserved.

contact |

your privacy

In Fig. Figure 9.1 shows how the resulting page looks in a browser. Although I don't usually use table borders, this time I drew them out to make the three parts of the page stand out more clearly in the illustration.

Rice. 9.1. Appearance of the page built in Listing 9.8

Template optimization

In the second (in my opinion, more preferable) option, the templates are designed as functions located in a separate file. This provides additional structure to your templates. I call this file the initialization file and store other useful information in it. Since we've already looked at relatively long header and footer examples, Listings 9.10 and 9.11 have been slightly shortened to illustrate the new idea.

Listing 9.10. Optimized site template (site_init.tpl)

// File: site_init.tpl

// Purpose: PhpRecipes initialization file

$site_name = "PHPRecipes";

$site_email = " [email protected]";

$site_path = "http://localhost/phprecipes/";

function show_header($site_name) (

<? print $site_name: ?>

This is the header

function show footer()

This Is the footer

Listing 9.11. Using an initialization file

// Include initialization file

include("site_init.tpl");

// Print title

show header($site_name);

// Body content This is some body information

// Display the footer Show_footer();

Project: page generator

Although most of the websites I've created have generated the main page content based on information read from a database, there are always a few pages that remain virtually unchanged. In particular, they can display information about the development team, contact information, advertising, etc. I usually store this “static” information in a separate folder and use a PHP script to load it when a request comes in. Of course, you have a question - if this is static information, what is the PHP script for? Why not load regular HTML pages? The benefit of PHP is that you can use templates and insert static snippets as needed.

<а href = "/static.php?content=$content">Static Page Name

Let's start by creating static pages. For simplicity, I'll limit myself to three pages containing site information (Listing 9.12), advertising (Listing 9.13), and contact information (Listing 9.14).

Listing 9.12. Information about the site (about.html)

About PHPRecipes

What programmer doesn't mix all night programming with gourmet cookies. Here at PHPRecipes. hardly a night goes by without one of our coders mixing a little bit of HTML with a tasty plate of Portobello Mushrooms or even Fondue. So we decided to bring you the best of what we love most: PHP and food!

That's right, readers. Tutorials, scripts, souffles and more. 0nly at PHPRecipes.

Advertising Information

Regardless of whether they come to learn the latest PHP techniques or for brushing up on how

to bake chicken, you can bet our readers are decision makers. They are the Industry

professionals who make decisions about what their company purchases.

For advertising information, contact

">[email protected].

Listing 9.14. Contact details (contact.html)

Contact Us

Have a coding tip?

Know the perfect topping for candied yams?

Let us know! Contact the team at [email protected].

Let's move on to building the static.php page, which displays the requested static information. This file (see Listing 9.15) includes the page components of our site and the initialization file site_init.tpl.

Listing 9.15. General output of static pages (static.php)

// File: static.php

// Purpose: displaying requested static pages.

// WARNING: this assumes that the file is "site_init.tpl" and that's it

// static files are in the same directory.

// Load functions and variables include("site_init.tpl"):

// Display the header show_header($site_name);

// Output the requested content include("$content.html"):

// Display the footer show footer();

Now everything is ready to build the main scenario. Just include it in the page

<а href = "static.php?content=about">Static Page Name

Advertising Information

Contact Us

If you click on any of these links, your browser will load the corresponding static page embedded in static.php!

Results

In this chapter, you became acquainted with the primary task for which PHP was created - dynamically building web pages. The following issues were considered:

  • URL processing;
  • building dynamic content;
  • inclusion and construction of basic templates.

The chapter ends with a page generator, a program that loads static pages into a template and makes it easy to support large numbers of static HTML pages.

The next chapter focuses on using PHP in combination with HTML forms to greatly enhance the interactivity of your site. And then - interaction with databases! You have a lot of interesting things to learn.


The world of free programs and useful tips
2024 whatsappss.ru