...

View Full Version : Can I use PHP to check client input?



paulinnorway
12-01-2006, 07:10 PM
Hi,

I'm starting to learn PHP so I'm still finding out what PHP can and cannot do. I don't mind doing the learning by myself, but it would be a nuisance if I spent ages learning PHP only to realise that I should have been using a different language!

It would be great if someone could tell me if the following is possible in PHP:

Here's the example in it's most basic format.....

I want the client to enter in a product number and click a "Get Price" button. I then want the product number to be sent to the server where a "get_product_price()" function (made by me) will use this product number in a calculation to find the price of that product. The result (ie. the price of the product) should then be sent back to the client.

It should look something like this:

Welcome to our shop....blah, blah....

To find the price of a product, enter the product number in the box below and click the "Get Price" button.

---------
| 12345 | <------ Client enters product number in this text box
---------


-----------
| Get Price | <------ Client clicks this button
-----------


This product costs:
---------
| $1,345 | <-------PHP returns the price to the client
---------


Is this possible using only PHP?
Do I need just one PHP file or several?
I'm a novice at programming and I'd really appreciate someone pointing me in the right direction.

Thanks:thumbsup:

Tyree
12-01-2006, 08:31 PM
Are you planning to use a database with PHP or JUST PHP?

This is easily done using MySQL in conjunction with PHP.

Otherwise, you have to store the prices and item numbers as variables within the file. But, yes, it's POSSIBLE either way. Using MySQL with PHP is the BEST way though.

paulinnorway
12-02-2006, 11:19 AM
Are you planning to use a database with PHP or JUST PHP?

This is easily done using MySQL in conjunction with PHP.

Otherwise, you have to store the prices and item numbers as variables within the file. But, yes, it's POSSIBLE either way. Using MySQL with PHP is the BEST way though.
Thanks for the reply:).

I'm planning to use just PHP. I'm sure it's better with PHP + MySQL, but I don't want to learn MySQL......I'm lazy;).
Besides, I don't think there's any need for me to use a database.

I'll describe how I want the program to work so you will have a better idea of the way I'm thinking....

There is an external website where I get the product price from. The web address would be in the following format:
www.getprice.com/whatever/product_number
So, once I get the product number from the customer I can get the corresponding web page, read it as a string, search the string, and extract the product price.
I know it's a bit messy, but at least I'm able to do the code for this.

The problem I have is understanding the PHP concept (sever side vs client side, etc), and the chain of events. I'm still trying to digest all this new and confusing information:confused:.

Is the anyway someone could explain to me the way this program would work in plain English or pseudo code? I think that would help me to focus my efforts and learning a bit more. I'd like to focus on a few trees instead of the whole forrest:D.

Any advice, suggestions, or questions are helpful and appreciated because they help me build a clearer picture of what I want to do.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum