Jump to content
Stef's Coding Community

Page from PHP to HTML


Guest mhd031

Recommended Posts

Guest mhd031

Hello,

 

I've got a PHP page on which I am collecting data for. I.e. there are a couple of input boxes.

 

What I want to do is to have a "save" button at the bottom that outputs that data to a HTML file.

 

I gues my question is, how do I convert my PHP page into an HTML page that contains all the dynamically generated variables?

 

(im building a small app that allows people to create simple html email signatures, and to do so i need a html file)

 

any help much appreciated...

Link to post
Share on other sites

If I understand you correctly, here is how I would go about doing it

 

When the save button is clicked:

-- create a new temporary file on the server (http://www.tizag.com/phpT/filecreate.php)

-- write your data in that file, using PHP's usual GET[] functionality to grab the input box data and save it in the appropriate spots (http://www.tizag.com/phpT/filewrite.php)

-- close the file once you are done writing to it

-- once the file is created, you could either offer the file for download, or allow them to copy/paste the created HTML code on the next page by reading the contents of the file into a textbox (http://www.tizag.com/phpT/fileread.php)

 

The only tricky part about this is that I am not sure if these temporary files you would be creating would delete themselves later, once they aren't needed. If a lot of people use the site, there would be a lot of temporary files created, consuming disk space (though text files are quite small, so it may not be an issue for a while). Perhaps if you want to allow users to copy/paste the HTML code, rather than downloading it, you could bypass the file create functionality, and simply do this:

 

Once the "save" button is clicked:

-- read in the input boxes using GET[]

-- using that data, create a long string that contains the correct HTML

-- output the HTML to the user

Link to post
Share on other sites
  • 2 weeks later...

If I understand your use case, I'd not try to generate an actual HTML page. Instead, I'd take submit the form back to the same page, but add a textarea with the code in it. That way, if they aren't happy with it, they can modify the original stuff, and resubmit to see their changes.

 

Having it in a textarea also makes it easy for the user to copy the HTML to paste into their forum profile.

Edited by lwsimon
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...