How to create a php form to accept 3 user inputs

Posted on 2012-08-21
Last Modified: 2012-10-25
Hello Everyone,

I am looking for some kind of examples or reference, that would let a user/customer to enter a promo code and a zipcode and hit submit,

once the submit button is hit, it should check the promo code with the allowed promo code and if its correct, direct them to the promo page.

The promo code will be in csv file on the server

any suggestions is appreciated.

Question by:niceoneishere
    LVL 107

    Assisted Solution

    by:Ray Paseur
    I think I would want to put all of the data into a MySQL data base.  A database is a "step up" from a CSV file, and can easily be populated from a CSV file.  With a data base you can search and update easily.  This is not nearly as easy with a CSV file.

    If you want this done quickly, consider hiring a professional PHP developer.  If you want to use it for your own learning opportunity, consider getting this book.  It's very readable and has great examples.  By the time you've worked through the book you will be able to understand the issues and write the code yourself.  But as a practical matter, you need to know that there are a lot of moving parts and the failure of any one of them can lead to the failure of the entire application.  If you have not programmed before, this would only be a good place to start if there is no economic risk involved (eg: It's a hobby project). has some information on how PHP can process HTML forms.  See "dealing with forms" here:

    If you've started writing some code and have specific questions, please post the code and questions, and I'll be glad to try to help.

    best regards, ~Ray
    LVL 12

    Accepted Solution

    I agree with Ray, you should really consider using a database instead, it will make the whole job much easier.

    The idea is that you will submit your data using a form (POST method).

    In PHP (server side) you should be able to read the submitted data by using:

    Open in new window

    Here is a quick example:
    <form action="submit.php" method="post">
    Name: <input type="text" name="txtName" />
    <input type="submit" />

    Open in new window

    PHP (submit.php):
    echo "Your name is: " . $_POST["txtName"]);

    Open in new window

    You will also have to know how to deal with MySQL, you can find many tutorials online:

    You can also check "Building a Database-Driven Web Site Using PHP and MySQL":
    LVL 1

    Author Comment

    Thanks for the replies, appreciate it
    LVL 1

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
    Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
    The viewer will learn how to dynamically set the form action using jQuery.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now