Jump to content

Archived

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

techiefreak05

'fwrite()' Questions

Recommended Posts

Hi, I'm using fwrite() to create an HTML page when a user successfully registers, is there anyway I can create the pages with pre=set HTML code in the page??

Share this post


Link to post
Share on other sites
I don't know what you mean by 'pre-set' HTML code. If you mean HTML string, yes. Just put that HTML code in a string variable and write it.

Ronald  ;D

Share this post


Link to post
Share on other sites
Right now, when I create the page, it's empty but I want them page to already have a "template", and how would I go about doing that?

Share this post


Link to post
Share on other sites
Simple create a php page which includes vars from another php page and evals and displays them displays them, and you write to the pag with vars for eg
the first time you write to the page it looks like
[code]
$body="helo";
[/code]
second time
[code]
$body="helo";
$body"$body world";
[/code]
and the pag which displays this would hav somehing like
put fread stuff in this scriipt
[code]
<?php
eval($code);
echo $body;
?>
[/code]
and th pag which writes uses fwrite like this
[code]
$txt = "new"
fwrite($file, "\$body=\"\$body $txt\";");
[/code]

it is a bit complicated but i would hav used this if i had to

Share this post


Link to post
Share on other sites
Make a template HTML file with, at the places that you want to insert stuff dynamically, some placeholder text,  such as e.g. {name} or {private msg} or whatever.
When you read the template into your storage, you dynamically replace these placeholders with the dynamic text you want (using str_replace or a regular expression). After that you write the output HTML file.

Ronald   ;D

Share this post


Link to post
Share on other sites
u see its not easy. you can ofcourse write to a simple text file and include it in a php page, like what one does in chat pags. the stuff is savd in a file which is shown in a stylish way.

edit another way

__________

Simple create a php page which includes vars from another php page and evals and displays them displays them, and you write to the pag with vars for eg
the first time you write to the page it looks like
[code]
<?php
$body="helo";
?>
[/code]
second time
[code]
<?php
$body="helo";
$body"$body world";
?>
[/code]
and the pag which displays this would hav somehing like
put fread stuff in this scriipt
[code]
<?php
include($page); // the above page
echo $body;
?>
[/code]
and th pag which writes uses fwrite like this
[code]
$txt = "new"
fwrite($file, "<?php \n \$body=\"\$body $txt\"; \n ?>");
[/code]

Share this post


Link to post
Share on other sites
You want to create a html file with some html code in it?

I hope that is what you are looking for...

If you are, try this:

[code=php:0]$html = file_get_contents("existing_html_file.html");
$file = fopen("new_file.html", "w+");
fwrite($file, $html);
fclose($file);
[/code]

If you are not looking for this, please ignore me :D


Share this post


Link to post
Share on other sites

×

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.