techiefreak05 Posted August 1, 2006 Share Posted August 1, 2006 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 to comment https://forums.phpfreaks.com/topic/16193-fwrite-questions/ Share on other sites More sharing options...
ronverdonk Posted August 1, 2006 Share Posted August 1, 2006 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 Link to comment https://forums.phpfreaks.com/topic/16193-fwrite-questions/#findComment-66957 Share on other sites More sharing options...
techiefreak05 Posted August 1, 2006 Author Share Posted August 1, 2006 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 to comment https://forums.phpfreaks.com/topic/16193-fwrite-questions/#findComment-66960 Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 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 egthe 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 likeput fread stuff in this scriipt[code]<?phpeval($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 Link to comment https://forums.phpfreaks.com/topic/16193-fwrite-questions/#findComment-66963 Share on other sites More sharing options...
ronverdonk Posted August 1, 2006 Share Posted August 1, 2006 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 Link to comment https://forums.phpfreaks.com/topic/16193-fwrite-questions/#findComment-66964 Share on other sites More sharing options...
techiefreak05 Posted August 1, 2006 Author Share Posted August 1, 2006 Um, yeah That kinda confuses me... sry :( Link to comment https://forums.phpfreaks.com/topic/16193-fwrite-questions/#findComment-66966 Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 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 egthe 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 likeput fread stuff in this scriipt[code]<?phpinclude($page); // the above pageecho $body;?>[/code]and th pag which writes uses fwrite like this[code]$txt = "new"fwrite($file, "<?php \n \$body=\"\$body $txt\"; \n ?>");[/code] Link to comment https://forums.phpfreaks.com/topic/16193-fwrite-questions/#findComment-66968 Share on other sites More sharing options...
Ifa Posted August 1, 2006 Share Posted August 1, 2006 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 Link to comment https://forums.phpfreaks.com/topic/16193-fwrite-questions/#findComment-66973 Share on other sites More sharing options...
techiefreak05 Posted August 1, 2006 Author Share Posted August 1, 2006 THANKS!! Its almost EXACTLY what im looking for!! OMG thank you!! :P Link to comment https://forums.phpfreaks.com/topic/16193-fwrite-questions/#findComment-66978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.