View Full Version : does javascript work with database?

low tech
Jan 28th, 2010, 08:33 AM
ok this is all hyperthetical and ground work (phishing) for me so any and advice will be warmly welcomed.

I would like to start and e-commerce site BUT:

I'm sure i should use javascript on client side to validate an order form BUT

1) server side, how is the order revalidated --- ie is javascript used again on server or use of another language?

2) could someone explain how information from order form is connected to an (SQL) database ---- and how is that database then updated?
What language is used? (I am talking about the general process here)

At the momment i'm researching SQL
and e-commerce database design

but I have no idea how all this is connected and where Javascript finishes and where I need to research further in oreder to put things together.

Any help would be fantastic

sorry for the novice questions.

low tech

Jan 28th, 2010, 08:47 AM
u need to use php to revalidate and php to run mysql queries

low tech
Jan 28th, 2010, 09:42 AM
thanks godofreality

so next I should research php.

I'm guessing that there is a specail place that these php files should be placed? or are they just placed in the root folder. You can see I know nothing of server side hahha

Anyway, i think i need to read on php and how it interacts with webpage forms/javascript?

hunter jordan
Jan 28th, 2010, 09:52 AM
Well, I think you should consult a professional web designer, who will help you out with all your queries. Good luck!

Old Pedant
Jan 28th, 2010, 08:07 PM
Don't assume you need/want to use PHP. I know that it's the darling of a lot of people here, but you should be aware of JSP and ASP and ASP.NET and even of maybe Cold Fusion. In my personal opinion, both JSP and ASP.NET are far superior to PHP, though both will require a paradigm shift on your part. All of a sudden, you won't be writing HTML pages, any more.

Certainly PHP and ASP are easier to integrate with existing HTML pages, but you have to ask yourself if existing HTML pages are the right way to go, ultimately.

Finally, whatever you do, don't create an eCommerce site yourself from the ground up. Aside from it being a lot of work, there are *WAY* too many ways for you to make monstrous mistakes that could be very very costly (in real money!) to you. Instead, find a good solid "starter kit" that you can adapt to your usage. And, yes, there are such products available free or at least cheap in all of those server-side technologies.

low tech
Jan 29th, 2010, 02:24 AM
Hi again

Thank you Old Pedant

Now that is some seriously excellent advice and a lot of food for thought. I will follow up on that advice.

I am interested in building an ecommerce site ----- very small scale of course ---- but the more I learn the more there seems to be to learn.

I am very intrigued by your suggestion of a 'starter kit' and wondered if you might be kind enough to elborate a little bit more on that.

I have a free css2 ecommerce site that I can adapt for learning


is that what you mean by 'starter kit'?.

I intend to create a mini mockup so to speak.

I am really interested in understanding what happens on the server side of an ecommerce site ----- how the information is handled.

I understand that a cgi profram takes care of form information for example.

BUT I don't understand what you do with the order onformation that is gathered on a web page --- how is that informtion is processed, by what means does it interact with a database that is set up.

for example lets say I have:

a web page
products and product pages
order form / shopping cart
payment method

###### what happens here is my problem. By what means does the above interact with below. From you r information I'm guessing that everytihng is actually taken care of server side including the web page itself? #######

a database.

I know this is a javascript forum and now this thread is off track but I sincerly do appreciate your insights and knowledge.

I just want to learn.

low tech

Old Pedant
Jan 29th, 2010, 02:43 AM
Not that one. There's no server-side code behind that. It may look pretty, but it's useless.

*MAYBE* you could combine that with something like this:
Not quite free, but close. Ehhh...but they say the encode their software, so you can't modify it.

I'd look harder for an all-in-one free solution. Open source.

Google is your friend. "shopping cart free php" or "ecommerce free php". See how many hits you get.

Old Pedant
Jan 29th, 2010, 02:46 AM
I'm guessing that everytihng is actually taken care of server side including the web page itself?

And though you can use CGI, directly, it's much much harder to use than PHP or ASP or JSP or even ASP.NET.

Anyway, I'm not a PHP person. I use ASP and JSP and dabble in ASP.NET, but I've just never gotten into PHP.

low tech
Jan 29th, 2010, 03:15 AM
Once again Thank you Old Pedant:thumbsup:

My job for today, follow up on yr advice and direction, starting now:-)


Jan 29th, 2010, 05:44 PM
you should use ajax

Old Pedant
Jan 29th, 2010, 06:25 PM

AJAX has its place, but to use it as the entire basis for an eCommerce site makes no sense. Oh, you might use it to accumulate entries in the shopping cart and/or report the shopping cart. But if you have dozens of categories of products and hundreds of products, you don't want to do that all via AJAX. (Not saying you couldn't, just that it would be a lot of work for little purpose.)

low tech
Jan 30th, 2010, 08:41 AM
Hi all

First let me say thanks to everyone who has contributed their thoughts thus far.

I have found merit in each opinion and i've learned from them.

In my initial question, I was unclear by what method the web browser (web page) interacted with data
on the server.

Putting aside for now JSP, ASP and ASP.NET because I haven't as yet researched these areas,
PHP seems to be a popular language used to link the web browser and the server.

Many of the shopping carts "starter kit" I have found seem to use PHP (tho I confess I haven't seen em all)

So that answers my original question.


However, many of these "carts" are either pig ugly or just plain annoying and time wasting, clicking from page to page only to find
out you have to log in at the end!! (eg http://www.giftsforeducators.com/ )

I'd like to have control of my frontend page (eg http://www.ivoog.com/ )

So my question now is:

What are the practicalities vs impracticalites of the following?

Using html to construct a local shopping cart that would open in a new window and through javascript would hold (remove) data coming from ANY page,
Basically keeping a runnnig tally of goods, cost etc

Using Ajax to make queries of product availability OR is this done at the end? OR both points
for example what if someone buys the last item just before you click to buy?
My products will be mainly one of a kind statues so informing the user available/unavialable will be important.

Lastly, from window -- info is sent via a checkout buton (Ajax?) to the backend shopping cart where one could then move on directly
to purchasing ie entering CC data etc details

Would this way create a lot of problems? Or is it doable practically?

EDIT just thought NOT sure if I'm allowed to include those web address ----- admin please edit if not allowed

Old Pedant
Jan 30th, 2010, 11:34 PM
I include web addresses all the time when they illustrate something and aren't trying to sell anything, so you should be okay.

The type of ecommerce system you just described is the type that I recommended against. Doing it all via AJAX *can* be done, but it just seems like a *LOT* more work, to me, for little purpose.

Don't worry about the *appearance* of an eCommerce site/package. You can easily change and control that part, yourself. It's the effectiveness of your features you should care about.

I kind of like that ivoog site. It's not the best kind of shopping experience for a store that expects to sell you lots of items in one go (e.g., a book store?), but it's pretty effective for a shop where most customers will buy only one item. You will notice that it is *not* AJAX-based (thought the cart summary that pops on probably is...but that's a nice compromise!). Are you saying that it's based on some free/low-cost ecommerce software??

low tech
Jan 31st, 2010, 02:36 AM
Hi there Old Pedant

Thanks for yr thought provoking insights.

Ok I didn't realize what I was asking was going agaisnt what you suggested.

So I thought what I was proposing was developing the frontend with html javascript..(Ajax)

I thought what you were saying was DON"T try to create the backend shopping cart and database

And I agree with that because as I see it the cart has the following role(I may have missed smthg)
it shows a final tally of all the product info sent to it
it somehow (I guess) does a final check to make sure all products are still available
it updates the datbase (not sure about web page?)
it moves on to take care of the security aspect --- payment --- addresses -- confirming emails etc etc

I like the ivoorg site because of its spaciousl own page approach.
it's uncompromised by a cart's design make up. (although I hear you when say don't worry about appearance, it can be changed)
It's not cluttered.
It doesn't make you click thro multi pages.
It seems to go easily to cart.
It doesn't really leave the page.

ONE click for DETAILS, ONE click to ADD cart. Nice simple. Page always in view.

It seems like an uncomlicated home made solution that intergrates a backend to take care of the
nitty grity secure stuff.

From pop on site goes to google checkout.(a little ugly)--- or at least that where I ended up . BUT I was thinking this is the point where
my shopping cart would take over. (the backend cart you suggested)

I was thinking that his cart collection of data (the pop on thing) would be ajax I was proposing smthg similar BUT are you saying that exactly the area I SHOULDN'T do?

Also a naggging question is how can the cutomer be sure product is available unless there is a check performed?.I don't see at what point ivoorg does that..

very interesting.
I certainly don't want to make a start on this until i'm clear of a workable direction in accordance with my level. (not high hahahaahaha)

Thanks for all yr feedback Old Pedant---- extremely helpful.

low tec

EDIT NOTE: some of the itmes I have in mind to sell will be unique one of a kind carvings. I expect an order of one. Whereas other smaller items may be joined up to make an order of multiple products.

low tech
Jan 31st, 2010, 03:39 AM
Hi Old Pedant

Just been looking the source of ivoorg and noticed that they link to


So am I right in thinking that they use a php cart as their backend AND that is what pops on/up when you 'view /add cart'?

ie not Ajax?


Old Pedant
Jan 31st, 2010, 05:38 AM
No, they are just using that company to do credit card processing for them.


See, the thing that is *WRONG* about the ivoog site is that it doesn't appear to be driven off a database.

It works only because, indeed, it has so few products.

Now try to imagine a more typical site. Let's say a clothing site.

So you have categories of clothes (men's, women's, pants, shirts, etc., etc.). You have some products that fit in multiple categories and should be shown in all categories. You have inventory that is constantly being updated and changed.

You *can't* use a static page design. It must be driven by the database. By the products and categories and maybe even sizes (if the user has stated a size preference) or colors (if the user has a color preference). And if you allow the user a "search" capability (and you should), then maybe you will search for "denim" and it will go across all categories. Again, the results *MUST* be dynamic. Fully dynamic.

Can you do that with an AJAX-based site. Yes. But it's much more difficult than a traditonal "paged products" site.

Notice that as fond as Google is of AJAX, the main google search pages are *NOT* at all AJAX based.

And, of course, there is always the argument that you need to support users who turn off JavaScript. Good luck, then, with an AJAX-based site.


It's the usual answer to most programming (and software design!) questions: "It depends..."

low tech
Jan 31st, 2010, 06:29 AM
Hi Old Pedant

haha ok in the very begining I read about generating HTML from live database, which promted me to ask the question does javascript work with database (I didn't know)

and now I know that php (or ASP etc) is needed to talk to database -----

but then I was under the assumption that creating a database driven site was a hard task and I should look at 'starter kit'

some kits include database and some don't either way I tried to find a way tohave the starter kit do the backend and use my own front page

BUT that has now brought us back to the database question hahah aha h aha

Old Pedant
I don't know about you --- but my head is spinning hahahahhahaha

I still don't know what approach to take to develop a small scale first time ecommerce site hahahhaa
ps that does't look like this


Old Pedant
Jan 31st, 2010, 10:12 PM
If by "small scale" you mean something like ivoog, where your product line doesn't change for months at a time, then doing as they have done--html pages with only the shopping cart done with backend processing--is a quite viable way to go.


You have to make up your mind. We can't do it for you.

low tech
Feb 1st, 2010, 02:21 AM
Hi Old Pedant

Thanks for all yr insights and helping me cover this as yet uncharted area.

I think I have an improved understanding of some of the process.

I will go with your original suggestion of starter kit shopping cart (with or owithout database depending on how they come) and create a page similar to ivoorg site.

Then I will test from there and see what problems arise.

Again, thanks for all yr time and effort and most of all yr patience:-)

low tech

EDIT Actually Old Pedant, I forgot to look at your other suggestion ASP. So I will take some time to familiarize myself with it frst before anything because my products tho few are likely to change often.
This seems like a good start.