Jump to content

Imbedding php in html....


alxsmth

Recommended Posts

I created a pure php file upload page a while ago and would like to incorporate it into my new css website, but i have had prolems getting it working as i have no experience in this and just attempted copying the php script straight into the new page, i would like it so that the index.php i created works within a frame on my website and uploads can be processed without having to reload the whole page because at present you click the upload button and not only does it go to a blank page it also does not work. If anyone requires any more info to help solve this topic please ask, any help is greatly apreciated....... Alex

Link to comment
Share on other sites

Creating a good design and development page, as I've learned recently, is a bit of a challenge so I don't blame you. My advice would be to try and break down the code so that the hard processing (the actual upload and things) are done separated from the HTML itself as much as possible. For example, I try and make sure that my pages look something like this now:

 

<?php
Whatever PHP processing code I need to add here
...
?>
<html>
<head>
<title>Whatever</title>
Then you can add a link to a stylesheet here easily
</head>
<body>
<form action=$_SERVER['PHP_SELF'] method=POST>
Then you finish your upload form in here
</form>
</body>
</html>

 

Obviously there's a little more to it than that, but that's the idea. I try and break them up as much as possible now if I can. Hopefully that helps =)

Link to comment
Share on other sites

Alternatively, you could implement a templating class to seperate everything for you, if you're making a site with many many pages then I'd recommend this, it's alot easier to edit the php than have to trudge through long lists of html aswell - often is the case that only the php needs to be edited, not the html. I think there's a tutorial on how to make your own on the phpfreaks site, short of that simply search google for smarty template or fast templates for two good already existing templating classes.

 

You could do what dswain suggested, and use php within the html, or you could use html within php using echo("<table=blah blah><tr><td></td></tr></table>") etc for example, there's lots of avenues you can go down.

Link to comment
Share on other sites

A templating class does sound nicer than any of the other solutions, so I'll agree with that (though I've never done it, so I don't know how involved it is). The only reason I say try to avoid the HTML within the PHP is because that's even harder to maintain, especially for other people who have to read your code. Just my experience talking at that point, but the templating system does sound good.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

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.