Writing a .php extension
Posted: Fri Dec 19, 2003 3:22 pm
I have a simple fwrite script to create new pages with. However, those new pages always never have an extension, so I have to manually change it. How can I have it write an extension (I only need .php) to those files I've created.
Code: Select all
<?php
include ("news/config.php");
$id = $_POST["id"];
$section = $_POST["section"]; //Use for later
$date = date("F j, Y");
$name = $_POST["name"];
$email = $_POST["email"];
$title = $_POST["title"];
$content = $_POST["content"];
$pass = $_POST["password"];
if ($password == $pass)
{
$filename = 'articles.php';
$file = file_get_contents($filename);
$fp = fopen($filename, "w");
fwrite($fp, "<a href=index.php?page=articles&id=$id>$title</a> - $date <br /><br />");
fwrite($fp, $file);
fclose($fp);
chdir($section);
$file = file_get_contents($id);
$fp = fopen($id, "w");
fwrite($fp, "<h1>$title</h1> Posted by: <a href=mailto:$email>$name</a> $date <br /><br /><br /><br /> $content</font> <br />");
fwrite($fp, $file);
fclose($fp);
?>