is there any way to get the name before i post, i want to get the name before i post becuase i want to delete a php file and create a new one instead of it

if(isset($_GET['id']))
{
	$query = "SELECT id, name, title, description, keywords, content, skin ".
	         "FROM pages ".
			 "WHERE id = '{$_GET['id']}'";
	$result = mysql_query($query) or die('Error : ' . mysql_error());
	list($id, $name, $title, $description, $keywords, $content, $skin) = mysql_fetch_array($result, MYSQL_NUM);

}
else if(isset($_POST['name']))
{
    $id = $_POST['id'];
	$name = $_POST['name'];
	$title = $_POST['title'];
	$description = $_POST['description'];
	$keywords = $_POST['keywords'];
	$content = $_POST['content'];
	$skin = $_POST['skin'];
    $updated = date("D, jS F, Y");
	
header("location:default.php?s=listpages");
	
	if(!get_magic_quotes_gpc())
	{
		$name = addslashes($name);
		$title = addslashes($title);
		$description = addslashes($description);
		$keywords = addslashes($keywords);
		$content = addslashes($content);
		$skin = addslashes($skin);
	}
	
	// update the content in the database
	$query = "UPDATE pages ".
	         "SET name = '$name', title = '$title', description = '$description', keywords = '$keywords', content = '$content', skin = '$skin', updated = '$updated'".
			 "WHERE id = '$id'";
	mysql_query($query) or die('Error : ' . mysql_error());
	
	// now we will display data
	// so strip out any slashes
	$name  = stripslashes($name);
	$title  = stripslashes($title);
	$description  = stripslashes($description);
	$keywords  = stripslashes($keywords);
	$content = stripslashes($content);
	$skin = stripslashes($skin);
	
	$oldfilename = $_GET['name'];
	
	// delete old php file from server
	$oldfilename = "$oldname.php";
	unlink($oldfilename);
	
	// Start - Update php file
	$filename = "$name.php";
	$template = file_get_contents("templates/default.php");
	$filehandle = fopen($filename, 'w') or die("can't open file");
	$addonhandle = fopen($filename, 'r+') or die("can't open file");
	$id = "<?php \$lastid = \"$id\"; ?>";
	$pageskin = "<?php \$skin = \"$skin\"; ?>";

	fwrite($filehandle, $template);
	$oldcontent = file_get_contents($filename);
	fwrite($addonhandle, $id."\n".$pageskin."\n".$oldcontent);
	fclose($filehandle, $addonhandle);
	// End - Update php file
Member Avatar for diafol

Sorry mate, can't really see what you want to do here. Could you spell it out stepwise (without the code)?

what kind of "name" you are talking about?

A little explanation of what your code does will help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.