OK, Here Goes, I hope someone can help with this, cause I'm going nut's trying to figure this out!
I am new to PHP and pretty much programing, in general. I am attempting to create a page where the owner of the Web site can go and input data that will update the correct file within the structure of the Web site.
Layout:
A calendar page that gets updated at least once a month (sometimes more).
I Have created a form page where the data can be imputed. (update.phtml)
I have a Template page (calendartemplate.phtml) and the page to do the updates (calendarupdate.phtml)
This is what I have tried thus far:
On submission, the "update.phtml" is directed to "calendarupdate.phtml" with the following code:
=======================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 FINAL//EN"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Calendar Update</title></head><body bgcolor="#000000" link="#64B3D9" vlink="#FFFF00" text="#FFCC99" topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><Center>
<table border=0 cellspacing=0 cellpadding=0 width=620><tr
valign=top align=left><td width=620><p align=center>
<form name="LAYOUTFORM" action="" METHOD=POST>
<input TYPE=HIDDEN name="date" value="<? print ($date); ?>">
<input TYPE=HIDDEN name="event" value="<? print ($event); ?>">
<?
$template = include("./calendartemplate.phtml");
$content = $template;
if (!$fp = fopen("./calendar_test.html" , "w")) {
print("Could not open file!");
} else {
fputs($fp, $content);
fclose($fp);
print ("<P> <B>" .
"File Saved Successfully." .
"</B>");
}
?>
<p> </td></tr></form></table></body>
=======================================================
This results in the information being displayed correctly in the browser but only the number "1" gets written to the external file (calendar_test.html).
I have also tried:
=======================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 FINAL//EN"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Calendar Update</title></head><body bgcolor="#000000" link="#64B3D9" vlink="#FFFF00" text="#FFCC99" topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><Center>
<table border=0 cellspacing=0 cellpadding=0 width=620><tr
valign=top align=left><td width=620><p align=center>
<form name="LAYOUTFORM" action="" METHOD=POST>
<input TYPE=HIDDEN name="date" value="<? print ($date); ?>">
<input TYPE=HIDDEN name="event" value="<? print ($event); ?>">
<?
$template = "./calendartemplate.phtml";
$fd = fopen($template, "r");
$content = fread($fd, filesize($template));
fclose($fd);
$fp = fopen("./calendar_test.html" , "w");
fputs($fp, $content);
fclose($fp);
print ("<P Align=Center> <B>" .
"File Saved Successfully." .
"</B> <P>");
print $content;
?>
<p> </td></tr></form></table></body>
=======================================================
This results in the information from "calendartemplate.phtml" being displayed in the browser and written to the file "calendar_test.html" but without the variables from "update.phtml"
I figure it's got to be something simple. I am using "Professional PHP Programing" as a reference.
RE: the first scenario, once the "calendartemplate.phtml" is merged with the variables from "update.phtml" and it is displayed correctly in the browser - is there a way to capture the HTML being displayed and write that to a file (calendar_test.html)?
Any feedback would be appreciated!!!