Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

floh

macrumors 6502
Original poster
Nov 28, 2011
460
2
Stuttgart, Germany
Hey everyone!

So, I want to create a simple website, and I have never done this (well, yes, but very basic and a long time ago). The website is supposed to have the following features:

- People can create user names (captcha?) and log in with them.
- They can submit some data (just a number and maybe the submission date)
- They can view a graph of their own numbers and an average of everybody else's
- They can log out

Now these features are very basic and don't need to be fancy. The number of users will probably stay below 100. Not knowing anything, I would have gone about it with PHP and a mySQL database, but I have never really used either. I have a lot of coding experience in C and some in Python and am generally not afraid of computers and editors. I own Rapidweaver (because it was included in a software bundle once) but have never used it.

My questions to you are:

1. Are PHP and mySQL the way to do this? Is there a better or easier way?

2. What would you use to draw and show graphs of some data on the website?

3. Would you recommend doing this with Rapidweaver? Can Rapidweaver easily manage a database, logins and a graph, or would I have to manually code the PHP and mySQL part anyways? Or would you recommend to use Rapidweaver for a layout and then edit the resulting pages by hand?

4. Do you (by chance) have any great tipps where I can get examples or pre-coded site sketches like this? It seems to me like many people would want this (a site with accounts), and I don't want to re-program the wheel. ;) This is supposed to be a "could you just quickly code this"-project... as always...

Thanks, and I hope I didn't insult you all with my complete newbie questions.

Floh
 

ghellquist

macrumors regular
Aug 21, 2011
146
5
Stockholm Sweden
Wordpress

Suggestion.
Look at the wordpress system. It solves a number of the things more or less directly (creating users, logging in) and there is a lot of ready plugins available that might already solve what you are planning to do. It will as well allow you to host the site without cost.

// Gunnar
 

floh

macrumors 6502
Original poster
Nov 28, 2011
460
2
Stuttgart, Germany
Look at the wordpress system. It solves a number of the things more or less directly (creating users, logging in)

Thanks, Gunnar. I know the wordpress system (my institute uses it for the webpage we distribute our simulation software through) and it is very convenient.

However, I see three small hickups with that:

1. It does not allow a user to easily create his own account, does it? The way I got to know it, accounts can only be created by an admin user. I would like to avoid that. But I could be wrong here.

2. The database connectivity isn't great. Users in wordpress are supposed to be users that can or can't view certain pages or that have editing capabilities. Basically setting the "page rights" like for users in Unix filesystems. The users are not supposed to be entries in a database, with editable data points associated with their account. I would probably have to hack a lot to get this working and could as well go with PHP directly.

3. Free webspace is great, but I already have that, because I work at a university. :)

Thanks anyways, and I may actually be wrong about these points.
 

rdas7

macrumors regular
Nov 17, 2002
165
22
London, England
I'm in precisely the same situation —*extensive experience in front-end code, but little hands-on with server-side (beyond accessing APIs that I usually have a hand in architecting, but not coding).

Look into PaaS and SaaS solutions such as Parse.com —*might be just what you're looking for! There are several other similar services.
 

ghellquist

macrumors regular
Aug 21, 2011
146
5
Stockholm Sweden
1. It does not allow a user to easily create his own account, does it? The way I got to know it, accounts can only be created by an admin user. I would like to avoid that. But I could be wrong here.

2. The database connectivity isn't great. Users in wordpress are supposed to be users that can or can't view certain pages or that have editing capabilities. Basically setting the "page rights" like for users in Unix filesystems. The users are not supposed to be entries in a database, with editable data points associated with their account. I would probably have to hack a lot to get this working and could as well go with PHP directly.

Hi.
I am in no way an expert, have only dabbled a bit on the corners with wordpress. I find it to be one (of probably many) shortcuts to solve things that otherwise would take a lot of my (not bugfree) code.
1. There are several plugins allowing users to register themselves with more or less security checks. Check this one as an example (buddypress). http://testbp.org
2. Agree on that part. But I believe that if you have already verified the user and has his name in a PHP variable (wordpress does that) it would be easy to access the MySql database to store stuff.

Anyway, beeing a lazy programmer, I personally try to steal as much as possible.
// Gunnar
 

TechnologyLasts

macrumors newbie
Oct 5, 2011
4
0
1. It does not allow a user to easily create his own account, does it? The way I got to know it, accounts can only be created by an admin user. I would like to avoid that. But I could be wrong here.

Users can create an account themselves with Wordpress. You don't even have to install any plugins; it's native to Wordpress. It's a checkbox in the settings of the Wordpress site, called "anyone can register". Just check that box and you're good to go.
 

floh

macrumors 6502
Original poster
Nov 28, 2011
460
2
Stuttgart, Germany
Users can create an account themselves with Wordpress. You don't even have to install any plugins; it's native to Wordpress. It's a checkbox in the settings of the Wordpress site, called "anyone can register". Just check that box and you're good to go.

Thanks everyone, not just you!

I'll consider using Wordpress in the future, it seems like a great option for many tasks.

Since I ended up planning to do a lot of database stuff anyways for this page, I just learned CSS, PHP, mySQL and Javascript (using flot for my plots) in one day and did the whole thing from scratch in another day (there goes my weekend). Yeah, these languages are amazingly simple, it's just the communication between them that took some effort and getting used to for me. So, if you stumble across this thread and you ever need to do something like this, I'll gladly send you my project. It's not perfect, but it seems to do what I wanted. :)

Thanks again for all the fast and kind replies.
 

crow33

macrumors newbie
Jul 9, 2013
1
0
Thanks everyone, not just you!

I'll consider using Wordpress in the future, it seems like a great option for many tasks.

Since I ended up planning to do a lot of database stuff anyways for this page, I just learned CSS, PHP, mySQL and Javascript (using flot for my plots) in one day and did the whole thing from scratch in another day (there goes my weekend). Yeah, these languages are amazingly simple, it's just the communication between them that took some effort and getting used to for me. So, if you stumble across this thread and you ever need to do something like this, I'll gladly send you my project. It's not perfect, but it seems to do what I wanted. :)

Thanks again for all the fast and kind replies.

Floh: Any chance you could send me the project? I'm looking for something similar and am getting ready to start a weekend of fun.
 

floh

macrumors 6502
Original poster
Nov 28, 2011
460
2
Stuttgart, Germany
Floh: Any chance you could send me the project? I'm looking for something similar and am getting ready to start a weekend of fun.

Sure, I just sent you a PM for exchange information.

In case anyone is interested, this is what the final project looked like:
http://zefrank.fahrenbergers.de/

It's nothing special, but I thought it would complete this thread. You'll have to create an account though to see the Javascript parts of it...
 

hharan

macrumors newbie
Jul 19, 2013
2
0
Hi Floh: I'm trying to learn PHP and this would be perfect. Can you share your code?

Thanks,
Hari
 

floh

macrumors 6502
Original poster
Nov 28, 2011
460
2
Stuttgart, Germany
Can you share your code?

Alright, I'll share it publicly. Just didn't want to spam the forum... maybe it helps someone.

Here is the code:
http://downloads.fahrenbergers.de/weight_loss_tracker.zip

And here is the eMail I wrote the first guy who asked for it, for some explanations and help:

So, here is the ZIP of my website files. I took out my database name,
user name, and password from "db.inc.php", other than that it is left
unchanged. Unfortunately, that means that there are very few comments in
there, since I programmed the site rather quickly in the end.

Some general (helpful?) thoughts:

The files "db.inc.php" and "session.inc.php" can be included at the very
top of a page to make sure it is only visible for logged in users and to
hide the database access files from the public for security. Still, with
this unprofessional code I would make sure that your database is only
accessible from the server itself, not externally, which can usually be
set in your provider's settings.

The file "plotdata.php" is a good example for connection of the
different languages: It contains a bunch of PHP code to calculate graph
data, including some calls to the mySQL database, and then a Javascript
part. Variables from the PHP part can be read via "json", with a line like:
var my_java_variable = <?php echo json_encode($my_php_variable); ?>;

If you are mainly interested in the PHP account creation/login part,
take a look at the file "createaccount.php", which is just called from
"createaccount.htm" via a submit form with data. If you do this, make
sure to hand the data at least a little more securely like "method=post"
(line 65 in the .htm file), and not within the URL.
The most crucial parts of the .php files that might be hard to
understand are:

>From "createaccount.php":
* lines 63-69: The variables given are escaped properly so they can
contain no commands that might mess up your database.
* line 104: The password is never saved in readable clear text. Instead,
a so-called "salt" is generated that is long and contains strange random
characters. This salt is then used as a base to encrypt the password so
the original string can not (well, hardly) be recovered. The encrypted
password and the salt are saved in your database, and you can easily
check if a password entered, combined with the salt of the username,
will create the same encrypted string. There is just no way to read out
the password.
* lines 51-60: This is a function to generate a "salt" that will make
the crypt function use the pretty secure "blowfish" algorithm for
encryption.
* line 106: This is the actual insertion of the new user into the
database. mySQL is very powerful, and I only scratched the surface of
it, but be sure to escape (with \"{$varname}\") strings that you want to
hand over and not escape numbers (like {$varname}). I think I ran into
some trouble with that...

>From "login.php":
* line 53 and 56 are a good example how to search the database and read
data from it. Be aware that line 53 alone does not yet read any data, it
only searches the database and stores a content handle with which you
can get the data.
* line 55 is a simple check if the username exists.
* line 63 is crucial to mark the user as "logged in".

"mailme.php" is a very simple way to have a user (if they entered a
valid eMail address) reset their password to something random if they
forgot it.

The rest of the files are pretty specific and you will probably not
learn a lot from them.

Good luck and have fun programming! )

Floh
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.