Jump to content
xisto Community
Sign in to follow this  

Backing Up User Forms As Static HTML

Recommended Posts

System: Activity System for use in UniversitiesUsers: Faculty membersScenario:User fills out a list of activites they participated in. Example: A faculty member attended a seminar about Object Orientated Programming. They record that seminar into their records by filling out a form and adding that activity into the database and identifying it with a designed term id. Spring terms are different than fall terms etc etc.We want to create html snapshots of these forms that can be included by a simple include('oldForm.html') into another form for review. We want to be able to include multiple files into the same page as well. In other words, we will be able to look at multiple "old" forms at the same time.I'm curious on how people would attempt to solve this problem.Below is sort of a simple diagram of what happens in order. We want to create the snapshot at step # 4.1.) Administrator informs everyone to fill out their forums2.) Faculty member fills out DYNAMIC form, and submits it for review3.) Administrator reviews form and decides to reject or accept4.) If accepted- snapshot is recorded of the Faculty members formIn order to build these dynamic forms we have lots of include files for different sections. IEWe have files for all the different activities:ScholarlyServiceCommitteesDevelopmentHow can I capture the content of all this and dump it to a html file? Is there anyway to do this?One way I found would be to use a URL to rebuild the form when it's time to make a copy, in the file_get_contents() method (as well as fget i believe). The only problem with this is each user has to login to use the system, so when I use that method and pass a url I just capture the login screen.I'm sure I'll need to clarify some things before there's a good answer, or you actually understand my problem.I hope someone can help, or offer advice.

Share this post

Link to post
Share on other sites

1.) Administrator informs everyone to fill out their forums2.) Faculty member fills out DYNAMIC form, and submits it for review
3.) Administrator reviews form and decides to reject or accept
4.) If accepted- snapshot is recorded of the Faculty members form

1. A form is set up.
2. The form information is stored in a table that stores all forms. One column in the table should tell if the form is approved or not. (Perhaps a boolean value)
3. The administrator, in a different form, approves the content. The column that tells if the form is approved or not should be changed to true or 1.
4. To create the snapshot:
First you'd retrieve the title from the title column in the table.

<?php		$a = mysql_query("SELECT * FROM table_name WHERE id='$id'");		$numrows = mysql_numrows($a);		for($i=0; $i<numrows; i++){				$title = mysql_result($a,$i,"title");				$content = mysql_result($a,$i,"content");		}?><?php		$ftitle = str_replace(" ", "-", $title); //replace spaces in the title with a hyphen		$f  =  fopen($ftitle.".html",  'w+'); //open the file. Since the file probably does not exist, it will create a new file.		$html =  "<html><head><title>$title</title></head>$content</html>"; //the html to insert into the file		fwrite($a,  $html);		fclose($a);?>

Ermm...I think the last part was what you were looking for, no? I didn't realize until a bit later. Stupid me! XP

Notice from vizskywalker:
Be sure to put your code in code tags

Edited by vizskywalker (see edit history)

Share this post

Link to post
Share on other sites

Thanks for the reply, but it's not exactly what I was looking for. I'm looking for a way to take the already html that exists in the document and save it to a file. The problem is the include files we have in place just prints html out and builds the form for us. Now lets say we want to capture that data while it builds it. Is there a way to do it?I've been playing around with file_get_contents($URL); but it's turning out to be a lot of trouble. I'm trying to pass the session data because I can't keep the same session open or something.Maybe someone could help me with that instead. How (when logged into a system) can I use file_get_contents and use the same session/session variables to retrieve a new file. I ended up passing the session variables in a query string then undecoding them once I got it over there. However it's still not functional. Some strange things happening, but overrall I receieved my variables and rebuilt my superglobal $_SESSION variable.I tried to simply pass the session id and then change my session id, but it didn't work too well either. Very confusing.

Share this post

Link to post
Share on other sites

I think something like this would help with my problem.


Let me see If I understand what you are talking about.

Admin says fill out your activity forms.

Faculty member fills out a dynamically generated HTML form and submits it.

A handler script takes the submitted form data and saves it to some type of database.

The administrator reviews the activity reports which are dynamically generated HTML forms that are dynamically filled in with the data from the database.

If the administrator accepts the report, a snapshot of the pre-filled form is saved as a Static HTML file.

If this is what you want to do then the object handler option you mentioned is the way to go! It should be in the script from step 4. This should save the file to a temporary directory. When the administrator "Approves" the report, then a second script should move the file to the permanant directory.


You would have to code a method of prunning older / unapproved reports. You'll have to carefully design a system of naming the files to ensure that you can find the right file at a later time.


Of course, this is going to use up a lot of diskspace since you are saving so much information. The form information is going to be much larger than the actual data information. Just seems strange to want to resave data that is already in a database.


Try to code your object buffer to include as little HTML as possible outside of the form to save space and time.


Hope this helps,


Share this post

Link to post
Share on other sites

Yes vujsa you are correct. I find it a bit strange too to save data as html than just pull from the database, but there are underlying reasons. 1.) Hard drives now days cost a lot less.2.) Rather than wasting server resources on pulling from the database we could include an html file 3.)The forms are dynamically generated, and the display of the forms can be altered...with that being said, the structure of the form would require more database entries to retain the past structures of the forms. It's much easier to simply dump the past forms than repulling everytime.Yes I do have a naming scheme in order to make sure every form is uniquely named with a purpose. Not to mention we're going to gzip the file. Rather than hold all of that in the database we're just going to file it away.I like your idea of doing the temporary file, but I'm doing an entirely seperate pull to write the file itself. This seperate pull basically cuts down on all the html it has to write, and is kept in a function, so we can use it anytime we want to backup that particular form. If we ever need it that is. A temp file is a good idea. I like that. Would save on database resources, it would just use server resources to strip the html of any characters we don't need.Thanks for the advice,-Brad

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.