Jump to content


Photo

'fwrite()' Questions


  • Please log in to reply
8 replies to this topic

#1 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 01 August 2006 - 10:48 AM

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??
Link shortener with advanced, detailed statistics:

http://tyny.us/

#2 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 01 August 2006 - 10:54 AM

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
RTFM is an almost extinct art form, it should be subsidized.

#3 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 01 August 2006 - 10:57 AM

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?
Link shortener with advanced, detailed statistics:

http://tyny.us/

#4 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 01 August 2006 - 11:05 AM

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
$body="helo";
second time
$body="helo";
$body"$body world";
and the pag which displays this would hav somehing like
put fread stuff in this scriipt
<?php
eval($code);
echo $body;
?>
and th pag which writes uses fwrite like this
$txt = "new"
fwrite($file, "\$body=\"\$body $txt\";");

it is a bit complicated but i would hav used this if i had to
I am a PHP Guru, ask me questions if you want to

#5 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 01 August 2006 - 11:07 AM

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
RTFM is an almost extinct art form, it should be subsidized.

#6 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 01 August 2006 - 11:09 AM

Um, yeah That kinda confuses me... sry :(
Link shortener with advanced, detailed statistics:

http://tyny.us/

#7 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 01 August 2006 - 11:12 AM

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
<?php
$body="helo";
?>
second time
<?php
$body="helo";
$body"$body world";
?>
and the pag which displays this would hav somehing like
put fread stuff in this scriipt
<?php
include($page); // the above page
echo $body;
?>
and th pag which writes uses fwrite like this
$txt = "new"
fwrite($file, "<?php \n \$body=\"\$body $txt\"; \n ?>");

I am a PHP Guru, ask me questions if you want to

#8 Ifa

Ifa
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationRauma, Finland

Posted 01 August 2006 - 11:23 AM

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:

$html = file_get_contents("existing_html_file.html");
$file = fopen("new_file.html", "w+");
fwrite($file, $html);
fclose($file);

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



I'm just a guy who likes to code for fun...

#9 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 01 August 2006 - 11:32 AM

THANKS!! Its almost EXACTLY what im looking for!! OMG thank you!! :P
Link shortener with advanced, detailed statistics:

http://tyny.us/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users