Create new page using permalinks php

To create a new page using permalinks in PHP, you'll need to follow these steps:

Step 1: Create a new PHP file

Create a new file in your website's root directory, e.g., new-page.php. This file will contain the code to generate the new page.

Step 2: Define the permalink

In the new-page.php file, define the permalink for the new page. This is the URL that users will use to access the page. For example:

$permalink = 'new-page';

Step 3: Create the page content

In the same file, create the content for the new page. This can be HTML, text, or a combination of both. For example:

$page_content = '<h1>Welcome to the new page!</h1><p>This is the content of the new page.</p>';

Step 4: Use the header function

Use the header function to set the HTTP headers for the page. This includes the Location header, which specifies the permalink for the page:

header('Location: '. $permalink);

Step 5: Output the page content

Finally, output the page content using the echo statement:

echo $page_content;

Here's the complete code for the new-page.php file:

<?php

$permalink = 'new-page';
$page_content = '<h1>Welcome to the new page!</h1><p>This is the content of the new page.</p>';

header('Location: '. $permalink);

echo $page_content;

?>

Step 6: Create a link to the new page

To access the new page, create a link to it in your website's navigation menu or elsewhere. For example:

<a rel="nofollow" target="_blank" href="new-page.php">New Page</a>

When a user clicks on this link, they will be redirected to the new page, which will display the content defined in the new-page.php file.

That's it! You've created a new page using permalinks in PHP.