its been a long time since i've done any PHP coding so I'm really back to square one, apologies in advance if I am missing something really obvious/trivial.
I am trying to create a form, which processes and submits the data and appends a piece of code to a specific section of an XML file.
This is what I've got
<? $title = $_POST['title'] ;
$author = $_POST['author'];
$filesize = $_POST['filesize'];
$pubdate = $_POST['pubdate'];
$duration = $_POST['duration'];
$summary = $_POST['summary'];
$key = '<itunes:category text="Business"></itunes:category>';
$newline = '<item>
<title>$title</title>
<link>http://example.com/CS/podcast/<? php echo($target_path);?></link>
<itunes:author>$author</itunes:author>
<itunes:summary><?php echo($summary); ?></itunes:summary>
<enclosure url="http://example.com/CS/$targetpath" length="$filesize" type="audio/mpeg"/>
<guid>http://www.example.com/CS/podcast/<? php echo($target_path);?></guid>
<pubDate><?php echo($pubdate);?></pubDate>
<itunes:duration><?php echo($duration);?></itunes:duration>
<itunes:keywords>My Podcast</itunes:keywords>
<category>Podcasts</category>
<itunes:explicit>no</itunes:explicit>
</item>';
//copy file to prevent double entry
$file = "list.xml";
$newfile = "listtemp.xml";
copy($file, $newfile) or exit("failed to copy $file");
//load file into $lines array
$fc = fopen ($file, "r");
while (!feof ($fc))
{
$buffer = fgets($fc, 4096);
$lines[] = $buffer;}
fclose ($fc);
//open same file and use "w" to clear file
$f=fopen($newfile,"w") or die("couldn't open $file");
/* uncomment to debug
print_r($lines);
print "<br>\n";
*/
//loop through array using foreach
foreach($lines as $line){
fwrite($f,$line); //place $line back in file
if (strstr($line,$key)){ //look for $key in each line
fwrite($f,$newline."\n");
} //place $line back in file }
fclose($f);
copy($newfile, $file) or exit("failed to copy $newfile");
echo "done";
echo "$newline";?>
The issue I seem to have is that it appends the code perfectly into the right place, but displays $title instead of the inputted title the same is true of
I think the issue is that you cannot have a variable within another variable, since it could be dangerous if anyone could just type code into forms, is there a way around this? I don't even need tight security as this would be soley for internal use.
Found
http://uk3.php.net/manual/en/function.eval.php but not been able to put it to good use.
Thank-you