Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Can I use PHP to check client input?

    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

  • #2
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Tyree View Post
    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.

    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.

    Any advice, suggestions, or questions are helpful and appreciated because they help me build a clearer picture of what I want to do.
    Last edited by paulinnorway; 12-02-2006 at 11:22 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •