Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Kris Byrum
Kris Byrum
32,636 Points

Updating website using a back end program

I'm looking to learn how to be able to update a website using another website.

Essentially, I would have a normal website for consumers to look at. On that page there is an events sections.

I'd like to learn how to make another more simple website that I can update my events into and then have it update my main website for consumers?

I was thinking that PhP or Rails may do something like this.

I'm attempting to plan out my next lesson.

thanks for the help!!!

2 Answers

You could do this with PHP combined with MySQL. I could be wrong here, but PHP + MySQL might make it easier to pull this off than Ruby if your two websites don't have the same web hosting. (You can have multiple websites run through the same web hosting server, but that's not often the case, unless you manage all of them yourself, and you might need to allow for the ability for this to change.) I don't know Rails, so someone else would have to verify that. But with PHP + MySQL, you could host the events list on one server and securely grab it from another server (if you set things up right). You could also avoid MySQL altogether and work with a JSON file instead. Real life case, iOS app store does tons of stuff through JSON data. You can perform a search query and get back a JSON file with a list of all apps that match your search. (But they have a robust database going on that's backing the data, and those JSON files are generated on the fly.) If you don't have too many events, and you're only setting up one site, you could use JSON and have PHP write-to-file to append the JSON data. But if you want to keep the events list locked down, you'd need to remember to put the JSON file above the root HTML directory on your server, so that it can't be accessed through the web, only by the server itself.

If you do PHP + MySQL, it's really not that much code. Learning the fundamentals might take a few days, but I could code this up in maybe 15-30 minutes.

Anyway, I recommend "Build a Simple PHP Application" and "Using PHP with MySQL" if you want to learn the stuff to get up to that. I'd be happy to toss some code and advice your way, but I'm sure you'd enjoy learning it more. Hope that helps!

Oh, I think I'm getting tired and missed the basic idea that you'd need to have your second site (the backend site for editing the events) be password-protected. You'd need to look into PHP form-submission to do that, so you can check (authenticate) a user-name and password. You can actually do that from simple "if" statements in your PHP code. There's not too much of a security difference between that and the more common ways people set up multiple user accounts and authentication for a website.