Hacker News new | past | comments | ask | show | jobs | submit login
Help: Creating servers, databases, queries.
3 points by _dt47 on March 7, 2014 | hide | past | favorite | 3 comments
Alright, so as of now i have a decent understanding of html, css, javascript and sql. I have made all the html and css files for my webpage, and in there there's a registration form. What i want is to create a server in my own computer(mac) on which i want to have a database that interacts with my webpage. When a user fills the registration form, i want it to interact with my server and the information be saved in the sql database. My questions are: 1) What should i use/read/learn to create my own server with a mysql database on my computer (without using a hosting service and already knowing sql)? 2)How do i "link" my webpage to my server so as they communicate?

I've heard about MAMP, apache, php... no idea what i'm looking for.




Starting with 2: an HTML form specifies a URL in the action property. When the form is submitted, the browser POSTs the field values to that URL.

This means you need a web server set up to handle POSTs to some URL with a script that will save the data into your DB. One very common way to do this is to run Apache as your web server and have it run a PHP script to massage the data & store it in a MySQL DB. Apache + MySQL + PHP = the AMP part of LAMP/MAMP/etc.

I'm sure you can find quick & dirty PHP example scripts to do this kind of thing. However, if you plan to put this out on the web at some point, you need to worry about all kinds of data integrity and security issues. In that case you're better off adopting some framework that will do all that work for you.

Before heading in that direction, I would research whether your needs are simple enough that you could use a no-SQL DB and have your browser-side JS post the form data as a json array straight into something like MongoDB.

All depends what you're trying to do in the long run, of course...


There is a version of XAMPP[1] for Mac - it comes out of the box with PHP and MySQL. I haven't actually used in on a Mac but on Linux and Windows it's ridiculously easy to stage and run a local site from it.

If i'm reading you right and you're actually thinking about hosting a site from your computer - don't. It's probably not going to work unless you only have like one user at a time and even then you're running the risk of someone rooting your computer and/or running afoul of your ISP if they have rules against running a site over their network, which they might.

If you pick a framework (of which there are many), any one of them is bound to have an ORM which will deal with the database using parameterized queries. Regardless, stay away from the mysql_* functions at all costs. Use PDO, or a library that supports it.

[1](http://www.apachefriends.org)


This is a good book for beginners: https://learnable.com/books/phpmysql5

It assumes you know HTML, but have no experience with servers, programming or databases. It walks you through creating your first database-driven website from scratch.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: