Forum Moderators: coopster

Message Too Old, No Replies

Form that creates a .html file and then replaces text in it

         

ball4121

2:02 am on Jan 28, 2006 (gmt 0)

10+ Year Member



Ok this will be hard to explain but bare with me.
Ok what I wan't is a form on my site in a location that only me and my friends that work on my site what I want it to do is generate the .html upload a file and in the .html it generates it has my sites template in it, and the forums will look as follows

____________ .html
whatever they put here is what the file will be called
_____________ META Title
whatever they put here will replace the strings on the above page with whatever they typed
_____________ META Desc.
same with meta title
_____________ Upload
upload the video or audio clip here
_____________ Upload files name
what they put here is the name of the video they uploaded like lets call it video.wmv and when they type it here it replaces a string on the generated html page. Like a replace the url in the video embed.
_____________ Video Description
replaces the video description under the video

Its really hard to explain any other ways, i'm hoping someone understands what i'm talking about. Because I ahve friends who know nothing about HTML.
I want it to be like YTMND's upload script (Can't give URL so do a google search :wink:).

Please HELP!

dreamcatcher

4:36 pm on Jan 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So, you want to replace data with something else?

How about str_replace()?

[uk.php.net...]

dc

ball4121

4:44 pm on Jan 28, 2006 (gmt 0)

10+ Year Member



I don't understand one bit of that link.

jatar_k

9:48 pm on Jan 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what dreamcatcher is referring to is having a template and having, I imagine, some kind of marker

<--METATITLE-->

for example(with a marker for each replacable value). You could then pull the file into a var and use str_replace to swap the value the user entered with it's appropriate marker inside the var. You can then open a file and write the value from your var.

ball4121

9:55 pm on Jan 28, 2006 (gmt 0)

10+ Year Member



jatar is it at all possible we can talk further on aim? You sound like you know what you are talking about.

You can aim me at <snip>

or post your aim and I can contact you.

If you don't have aim I also have Yahoo Instant Messanger.

Thank you.

[edited by: jatar_k at 3:59 am (utc) on Jan. 30, 2006]

dreamcatcher

12:07 am on Jan 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What jatar_k said is spot on. I figured you had some slight knowledge of PHP, sorry.

ball4121, it sounds like you are a little out of your depth with what you are trying to do. You might want to grasp some PHP basics beforehand. I doubt jatar_k has time to guide you through the process on a messenger.

dc

jatar_k

4:28 am on Jan 30, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> You sound like you know what you are talking about

so do tons of members here, you're in good hands. dreamcatcher knows the drill ;) I am happy to volunteer time here but I work for money outside of this and mostly I spend time with my daughter (she's been lovingly throwing up all over me for the past 2 days, such a charmer).

let me get a little more specific for you

1. create the template for your html page, mock one up. create a full page that looks exactly like you want and check it all out in your browser.

2. take this same html template and replace each element you would like to be replaced by user input with a tag like I showed you. Here is a rough example

<html>
<head>
<title><--TITLE--><title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="<--METADESC-->">
<meta name="keywords" content="<--METAKEYS-->">
</head>
<body>
<p><--IMGAUDNAME-->
<p><--FILEDESC-->
</body>
</html>

code the upload script

3. so we now grab the info input by the user, we clean it all, then we start building our file from the template with the user input

4. get the contents of the template using file_get_contents [php.net]. Afterwards we will have all the content in a single variable.

5. use str_replace [php.net] to swap the user input with our place holders for title, metadesc, metakeys and filedesc.

6. since the content could be either an image or an audio file we can't include the tag in our template though we did include a placeholder for the full tag. We figure out which they gave us and use php to create the appropriate html for the image or audio. We then swap the finished tag(s) with the <--IMGAUDNAME--> place holder.

7. we need to open a file with the filename given by the user using fopen [php.net]. fopen will create the file if it does not already exist.

8. use fwrite [php.net] to write the information to our new file.

9. use fclose [php.net] to close the file pointer

10. [optional] make sure in your initial test that the new file has the right permissions (that it will be viewable through a browser). If it does not then you may need to use chmod [php.net]

that make it a little clearer?