This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
remiX's profile picture

Free website hosts with built-in webpages

Started by remiX, 06 February 2013 - 05:10 PM
remiX #1
Posted 06 February 2013 - 06:10 PM
Hey guys, I'm looking for a free website host that at least has the following:

Login system / or some kind of anonymous commenting ( to add links )
Has it's own webpages for me to edit
Has a 'link' page that is able to take links with name, url, description.

I can't find any after googling :huh:/>
Dlcruz129 #2
Posted 06 February 2013 - 06:23 PM
You could use 000webhost.com. I think Wordpress would be best for the actual web page stuff. .
tesla1889 #3
Posted 06 February 2013 - 06:29 PM
000webhost is great, as long as you have HTML and/or PHP knowledge
Dlcruz129 #4
Posted 06 February 2013 - 06:41 PM
000webhost is great, as long as you have HTML and/or PHP knowledge

Or just upload something like Wordpress.
remiX #5
Posted 06 February 2013 - 10:02 PM
Hmmm, okay, I'll check it out later when I'm at home.

Does it allow registration/login or not? Can people (anyone) post things (links/pictures) onto the website?
Dlcruz129 #6
Posted 07 February 2013 - 04:29 AM
Hmmm, okay, I'll check it out later when I'm at home.

Does it allow registration/login or not? Can people (anyone) post things (links/pictures) onto the website?

It's a blogging system. You can make pages, people can comment, etc.
remiX #7
Posted 07 February 2013 - 04:45 AM
Yeah, figured :P/>

I'm trying to figure out how to make it able for users to add a link to a page that then is saved to a Database.
And then get the information from that database using ComputerCraft.

Can this be done?
PixelToast #8
Posted 07 February 2013 - 04:48 AM
yea, you have to use PHP and the HTTP api
remiX #9
Posted 07 February 2013 - 04:59 AM
yea, you have to use PHP and the HTTP api

Yes, I know that.

I know a little about PHP and MySQL but I have no clue how I would use the HTTP api to extract information from the MySQL table.
Cranium #10
Posted 07 February 2013 - 05:06 AM
Well, as long as the information is in plain text, you can pull the info directly from the server using http.get, or get a response using http.request. You can have the server respond to certain requests with the information you want using PHP. I don't know how to do it server side, but the HTTP api is fairly straight forward.
Sammich Lord #11
Posted 07 February 2013 - 05:22 AM
Go to http://w3schools.com for some PHP and MySQL tutorials. Just have a PHP script extract data from a MySQL database depending on the variables you pass via the http.get function.
remiX #12
Posted 07 February 2013 - 05:40 AM
But is this possible with 000webhost websites? The extracting of MySQL tables. Not sure if I can make my own PHP script.

Could anyone give me an example of how extracting the information would work.
Sammich Lord #13
Posted 07 February 2013 - 06:41 AM
You quarry the data from the database and echo it.
zekesonxx #14
Posted 07 February 2013 - 08:11 AM

<?php
//Who wants to bet this won't highlight correctly?
mysql_connect("localhost", "YOURMYSQLUSERNAME", "YOURMYSQLPASSWORD");
$query = mysql_query("SELECT * FROM YOURTABLEHERE");
echo json_encode(mysql_fetch_assoc($query));
//Really, you should be using PDO and perpared statements. I'm not typing that out, and I doubt 000WH has support for it.
?>


--You will need a pure-Lua JSON decoder. There are a few of these floating around.
print("Now fetching data from website")
result = http.get("LINKTOYOURPHPSCRIPT").readAll()
if result ~= "" then
results = json.decode(result)
else
print("Unable to fetch data from website")
end
remiX #15
Posted 07 February 2013 - 08:34 AM
Yeah I got it with this:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">

	<head>
		<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
		<title>Database Info</title>
	</head>

	<body>
		<h2>Information in the database</h2>
		<?php 
			// Connects to your Database 
			mysql_connect("xxxx", "xxxx", "xxxx") or die(mysql_error()); 
			mysql_select_db("xxxx") or die(mysql_error()); 
			$data = mysql_query("SELECT * FROM xxxx") or die(mysql_error());
			Print "\n<!-- Start of Table -->\n";
			Print "<table border=1 cellpadding=15>\n";
			Print "\n<!-- First row (Headings) -->\n";
			Print "<tr>\n";
			Print "    <th>ID</th>\n";
			Print "    <th>User</th>\n";
			Print "    <th>Title</th>\n";
			Print "    <th>URL</th>\n";
			Print "    <th>Description</th> \n";
			Print "    <th>Post Date</th> \n";
			Print "</tr> \n";
			while($info = mysql_fetch_array( $data )) 
				{
					Print "<!-- ID NO. <ID>".$info['id']."</ID> -->\n";
					Print "<!-- USER <USER>".$info['user']."</USER> -->\n";
					Print "<!-- VIDEO_TITLE <TITLE>".$info['video_name']."</TITLE> -->\n";
					Print "<!-- VIDEO_URL <URL>".$info['video_url']."</URL> -->\n";
					Print "<!-- VIDEO_DESCRIPTION <DESC>".$info['video_desc']."</DESC> -->\n";
					Print "<!-- VIDEO_TIMESTAMP <POSTDATE>".$info['video_timestamp']."</POSTDATE> -->\n";
					Print "<tr>\n"; 
					Print "    <td>".$info['id']."</td>\n";
					Print "    <td>".$info['user']."</td>\n";
					Print "    <td>".$info['video_name']."</td>\n";
					Print "    <td>".$info['video_url']."</td>\n";
					Print "    <td>".$info['video_desc']."</td>\n";
					Print "    <td>".$info['video_timestamp']."</td>\n";
					Print "</tr>\n";
				}
			Print "<!-- End of Table -->\n";
			Print "</table>\n"; 
		?> 
	</body>
</html>		

Works brilliantly. Thanks