Jump to content

[SOLVED] PHP ifram principle


justinede

Recommended Posts

Hello Freaks,

 

I am looking for code that will act like an iframe and put content from one of my pages into another. Kind of what wordpress does, they have index and they call in the header and footer and comments.

 

basically i have a website where i have last updated at the bottom and instead of going to all of my 10 pages and editing it over and over again, i want to have that info in just one file so i only have to edit it once. I could do this with an iframe, but i hate frames and i know you can do it in php so thanks in advance.

 

Justin

Link to comment
https://forums.phpfreaks.com/topic/149362-solved-php-ifram-principle/
Share on other sites

my bad... missunderstood your question...

maybe I get it right this time then :P

 

you could make a file named "lastupdates.php" or w/e you want.. the just place <?php include("lastupdates.php"); ?> wherever you want it on your page...

 

if i missunderstood again, ima give up :P

hahah same here. lol

 

ok so now I have to parts that are php included.. simple html and such..

what if i wanted to have like update.php and inside that, you would have two text boxes with the html from the two different included files.

 

 

basically so i can change stuff in one page.

haha ok alright let me explain.

 

so suppose in my site, i have a recent news sidebar and a last updated div in my footer.

i got both of them in separate php files using your include code (<?php include("new.php"); ?>).

 

now instead of opening sidebar.php and updated.php to edit the content, i want to open up manage.php and be able to change the content in those to files from there.

 

understand me know? xD

yeah now i get the question.. just ain't sure why u wanna do it like that xD

 

maybe you could try making separate textareas in manage.php loading the info from new.php and lastupdate.php

 

then you edit the content in the textareas and use fwrite or something?

 

not sure, but that would be my first guess ;)

yo so i got this bit of code somewhat working. But, it has the content already filled in with $somecontent = "add this..."; I want it to be what ever i type in the textarea that i named somecontent. Also, i want it to read out the current file in the textbox and edit from there.

 

<?php
$filename = 'test.txt';
$somecontent = "Add this to the file\n";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

    // In our example we're opening $filename in append mode.
    // The file pointer is at the bottom of the file hence
    // that's where $somecontent will go when we fwrite() it.
    if (!$handle = fopen($filename, 'a')) {
         echo "Cannot open file ($filename)";
         exit;
    }

    // Write $somecontent to our opened file.
    if (fwrite($handle, $somecontent) === FALSE) {
        echo "Cannot write to file ($filename)";
        exit;
    }

    echo "Success, wrote ($somecontent) to file ($filename)";

    fclose($handle);

} else {
    echo "The file $filename is not writable";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.