PHP Graph and email

Furr

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,067
Wonder if anyone could help me.
Now I'm pretty proficient in Java, SQL, etc. But I'm going to be building a web site in late May for a client.

How they want the site is basically a login section, question section and thats it.

So a user logs in and is presented with a page of questions, these questions are based on sliders. Once completed the user submits and is done.

What i then need to do is for that data to be used to create several bar charts, 5 questions 5 charts. The charts to then be converted to a pdf along with an XML document containing the data. I'm thinking that PHP would be best for this as it has a PDF function.

Questions are:
  • Is there a better way to do this that anyone can think of?
  • How to created the bar charts/graphs et al. Does PHP have this kind of function?
  • What is the best way to get the data send in emails to different email address based on different login details?
  • How different is it do code in a scripting language compared to an OO language? I imagine a lot of it is procedural based.

Got a while before I have to do this and 2 and a half weeks to get it done. But any insights you super doods could give would be appreciated.

Ta
 

kirennia

Part of the furniture
Joined
Dec 26, 2003
Messages
3,857
javabeans are fantastic for that sort of a job; would need more information on exactly you need.

i.e. do they login from a database or are they classified as a new user when they do the test?

While I have a program which reads a user login using an access database, session beans and could help with outputting xml, I wouldn't know how to put them into charts :( I do have to say though, the website I've made does have some security flaws (2nd year, 7 module credits, you can't expect more) but I'm sure you could sort them out if you want a look at the code at some point.

It's all still made using jdeveloper and as such I haven't uploaded the website...especially seeing as the final bit, the cart didn't work for it.
 

Furr

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,067
There would definitely be a database involved for the login, as the details for each group will be specific.
The Graphs will have some Default/Average values pre-entered in the database bases on the Group that the user logs in with. This is so that users belonging to a particular group who input their values will have those values rendered alongside the default values particular to their group for the client to compare.

The site outline is:

Many users are given a group login and password
The Group relation in the DB has among its attributes Login and Password, email, default values,

User interaction
  • User enters Login & Password
  • Authorisation
  • Complete Questions page
  • Submits and done

The scripting will take these submitted values and render the graphs, then output this all to one PDF file. It will also take the values and put them into an XML file. It then sends these two files via email to different email addresses based on group details used to log in with.

This is the initial idea, and I'm sure I would do it differently, but this is how the client wants it, at the moment I'm think XML as I believe a spreadsheet editor such as the newer Excels can take an XML file and convert it into a table. But if not will see about other file formats.

But yes, the one bug bear that I'm not sure how to do yet is the graph creation, PDF compilation and subsequent email.
 

kirennia

Part of the furniture
Joined
Dec 26, 2003
Messages
3,857
I have to say, I honestly don't know anything about PHP but if you decide to use anything java side for a login or whatever, I'm more then happy to help out (my code for it is pretty easily adaptable) so long as it's after the 15th (final exam). It will, afterall, keep me brushed up on my application side of java which has been out of sight, out of mind the last couple of weeks :)

I could make the program draw the graphs in J2D but tbh, it's really crap to use anyway, heh.
 

Furr

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,067
Cheers, yup the reason i'm not doing it now is second year CS exams... eurgh. Was just looking a Ruby too, going from Java to it seems quite easy.
 

Jonty

Fledgling Freddie
Joined
Dec 22, 2003
Messages
1,411
Hi Furr

Just a flying visit. PHP has graph functions included, as well as email, PDF, XML and everything else you need. The graph functions aren't amazing, but there are third-party scripts available if you need something more sophisticated (I'm also a little curious why you need XML data as well as the PDF, as most people won't know what to do with the XML. If you want a compromise, maybe look at using one of the new Office documents formats that are based on XML Edit ~ Sorry, I just noticed your second post).

As for users, you could store all the user information in a simple database. When a user logs in, they are authorized against the database, and this would then make it easier to send the emails to the appropriate place.

Finally, I don't know how easy PHP is to code, but the PHP manual is very helpful, and there are many tutorials on the net covering virtually everything PHP can do.

Kind regards
 

LordjOX

Part of the furniture
Joined
Dec 22, 2003
Messages
3,886
Heya Furr.

If you know C or Perl or any other scripting language you'll find php easy to learn and powerful.
It supports OO but it's built on more procedural languages like beforementioned languages. You have classes, class variables, class functions, subclasses and can also make globals and also Php keeps track of magic variables like $_SERVER or $_COOKIE. That keeps track of alot of metadata about the client browsing the site, cookies etc.
Refer to the php manual for more.

I'd start making mockups giving an idea how the site layout will be and then request specs from the client. Exactly what the user can do, what the system will do etc. You've mostly outlined this in the OP.

Then construct the database. PHP is very popular together with Mysql but it has libraries for postgres, mssql, oracle, you name it. LAMP is a term (software bundle) which means Linux-Apache-Mysql-Php. www.phpmyadmin.net is a good tool for managing the database with Mysql.

Now you can make login / logout and authentication mechanisms in php. This is easily accomplished with HTML POST forms and having php handle it. Use session or cookies to handle logins.

The questionairre:

Suggest Google Charts for charts etc, very powerful and professional API which can be interfaced with just about anything. Developer's Guide - Google Chart API - Google Code

Php mail function: PHP: mail - Manual

Php PDF libraries: PHP: PDF Functions - Manual

Lastly design the site after specs with W3C standards, XHTML and CSS for layout and design. Use Smarty : Template Engine for separating your business layer (with business logics) and the view.

Lastly a note about developing in Php. Usually you keep a 3-layer system. With seperate view, business logic and data access that talk to eachother but don't mingle or procreate. Standard systems development. There are frameworks for TDD, but not as widespread as in Java with JUnit etc.

Good Luck!
 

Chilly

Balls of steel
Joined
Dec 22, 2003
Messages
9,047
Glad it turned out OK. PHP is easy isnt it? Especialyl for this kidn of very simple job where using a more meaty language like Java has overheads that are not always justified by the scale or speed required.
 

Users who are viewing this thread

Top Bottom