Create new page using a href php
Here is an example of how you can create a new page using an a
tag with a PHP link:
<a rel="nofollow" target="_blank" href="create_new_page.php">Create New Page</a>
In this example, the a
tag is linking to a PHP file called create_new_page.php
. When the user clicks on the link, the browser will send a request to the server to load the create_new_page.php
file.
In the create_new_page.php
file, you can use PHP code to create a new page. For example, you could use the following code to create a new page with a title and some content:
<?php
// Get the title and content from the user
$title = $_POST['title'];
$content = $_POST['content'];
// Create a new page
$page_id = mysql_insert_id();
$query = "INSERT INTO pages (title, content) VALUES ('$title', '$content')";
mysql_query($query);
// Redirect the user to the new page
header('Location: view_page.php?id='. $page_id);
exit;
?>
In this example, the create_new_page.php
file uses the mysql_insert_id()
function to get the ID of the new page, and then uses a SQL query to insert the title and content into the database. Finally, the file uses the header()
function to redirect the user to a view_page.php
file, passing the ID of the new page as a parameter.
You can then create a view_page.php
file to display the new page:
<?php
// Get the page ID from the URL
$page_id = $_GET['id'];
// Retrieve the page data from the database
$query = "SELECT * FROM pages WHERE id = '$page_id'";
$result = mysql_query($query);
$page = mysql_fetch_assoc($result);
// Display the page
echo "<h1>". $page['title']. "</h1>";
echo $page['content'];
?>
This is just a simple example, and you will likely want to add more functionality and security to your page creation system.