Jump to content

PHP, create and upload a HTML page please...


yoshida

Recommended Posts

Hi.I'm running a website (d'uh) but my ISP's webspace doesn't run PHP. The folks I'm running the site for don't want to lease server space that does. So I'll have to create the pages on my localhost and have them uploaded as HTML. The pages are not interactive.Here's what I want to do: whenever I need to update the site I use a form, and when I hit 'submit' the article is added to a database. I already created a script to read data from MySQL and put it in DIVs. But it's still a PHP extention. Can I use the same script to create a HTML page on another location? Better yet: can I use the same script to create multiple pages, and have them uploaded to my ISP's webspace? They don't support FTP.Help appreciated. Thank you.

Link to comment
Share on other sites

I can't think of a way straight off that you can upload to a remote server without FTP. If you figure a way out, I have a script you can use.

<?if ((!$_POST[post_author]) || (!$_POST[post_title]) || (!$_POST[post_content])) {	header("location:show_makepost.php");	exit;}// set the date, check the post authorputenv("TZ=America/Denver");$created = date("l, F jS, Y - g:i A"); $today = date("Y-m-d");$author = $_POST[post_author];$title = $_POST[post_title];$content = $_POST[post_content];// start putting it into the database$connection = @mysql_connect("localhost", "username", "password") or die(mysql_error());$db_name = "database";$db = @mysql_select_db($db_name, $connection) or die(mysql_error());$sql = 'INSERT INTO `posts` (`title`, `day`, `date`, `author`, `content`) VALUES (\''.$title.'\', \''.$today.'\', \''.$created.'\', \''.$author.'\', \''.$content.'\')';$query = mysql_query($sql, $connection) or die(mysql_error());?>

Link to comment
Share on other sites

Looks good, but I already know how to insert post data into a database.The real issue is how to write a script to generate a page with a HTML extension.Thanks for responding anyway.By the way: I don't mind uploading the files manualy (the webspace looks like a shared folder) but it's simply inconvenient.

Link to comment
Share on other sites

Oh...well then this would be better for you

<?$filename = $_POST[pagename].".html";$filedata = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><head><title>Page 1</title></head><body>Content</body></html>";$file = fopen($filename, "w+") or die("Couldn't open file.");fwrite($file, $filedata) or die("Couldn't write to file.");fclose($myfile);?>

In the page content you can use the $_POST feature to insert dynamic content based upon the form you used to create the page. Let me know if you need any more help with this.

Link to comment
Share on other sites

Thanks, I'll give it a try.(So that's with the !DOCTYPE html PUBLIC tag I see in just about every source code..?)Do you know if there's a howto about this on the web? I'll browse the w3schools tutorial tomorrow (it's already ten in the evening where I live).

Link to comment
Share on other sites

That will create the page with the doctype, yes.This page has a listing of all of the PHP filesystem functions and this page has a good tutorial about how to create files with PHP.

Link to comment
Share on other sites

I'm running a website (d'uh) but my ISP's webspace doesn't run CSS.
What do you mean by that? Your host (not ISP, ISP is something else) doesn't have to "run" CSS, or support it, or anything. All you need to do is upload your HTML and CSS to the server, and reference the CSS in the HTML. The server doesn't do anything for the CSS that it doesn't do for the HTML, it responds the exact same way.If you are trying to host a website on a server that doesn't let you run PHP, doesn't give you access to a database, or doesn't give you FTP access, then you really need a better host. Look at geekhosting.com, or check the thread where people pimp their hosts. $2/month is not too much to pay for a server that lets you do what you want..
Link to comment
Share on other sites

What do you mean by that?  Your host (not ISP, ISP is something else) doesn't have to "run" CSS, or support it, or anything.  All you need to do is upload your HTML and CSS to the server, and reference the CSS in the HTML.  The server doesn't do anything for the CSS that it doesn't do for the HTML, it responds the exact same way.If you are trying to host a website on a server that doesn't let you run PHP, doesn't give you access to a database, or doesn't give you FTP access, then you really need a better host.  Look at geekhosting.com, or check the thread where people pimp their hosts.  $2/month is not too much to pay for a server that lets you do what you want..

Miscommunication. I intended to say: doesn't run php. I've been writing more css than php lately so mistakes happen. :) Fixed.When I say 'my Internet Service Provider's webspace' I assume you'd understand it's the webspace that comes with my internet connection in which I can host html files and such to be viewed by the common masses. When I say 'it doesn't run PHP' I assume you'd understand it doesn't parse PHP files.Please don't try to catch me in the Dungeons of Babylon, it's hard enough as it already is. :)Nakor, thanks for helping out. Have a candybar of your choice. :) I'll make sure to mention you somewhere on the about page of my site.
Link to comment
Share on other sites

A lot of people use host and ISP interchangeably, but your ISP and host are the same company. Got it.There's a simple solution here:

The folks I'm running the site for don't want to lease server space that does.
"I'm sorry, your site can't do that with the host it has now. How about you pony up $24 for a year of hosting."
Link to comment
Share on other sites

I'm one of the folks I'm running the site for. Expenses are already high enough as is, without any real cash flowing in. So we gotta cut corners where ever we can. It's not like articles are added on a daily basis, let's say once every two weeks. The only thing I use PHP for is to script the way articles are displayed (in a series of DIVs). I can change the site by either changing the CSS or the script and adding new items will be a breeze.At least that's the theory, once I get the script to create HTML pages.For all the good it will do: here's the site in it's preliminary state (post-dev). If I get all the scripts to work I'll add English pages. That's right: I'm a Dutch webdesigner.

Link to comment
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
×
×
  • Create New...