• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

How to create a php form to accept 3 user inputs

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.

Thanks
0
niceoneishere
Asked:
niceoneishere
  • 2
2 Solutions
 
Ray PaseurCommented:
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).
http://www.sitepoint.com/books/phpmysql5/

PHP.net has some information on how PHP can process HTML forms.  See "dealing with forms" here:
http://us.php.net/tut.php

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
0
 
Mohamed AbowardaSoftware EngineerCommented:
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:
$_POST['fieldNameHere'];

Open in new window


Here is a quick example:
HTML:
<html>
<body>

<form action="submit.php" method="post">
Name: <input type="text" name="txtName" />
<input type="submit" />
</form>

</body>
</html>

Open in new window


PHP (submit.php):
<?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:
http://www.freewebmasterhelp.com/tutorials/phpmysql/

You can also check "Building a Database-Driven Web Site Using PHP and MySQL":
http://dev.mysql.com/tech-resources/articles/ddws/
0
 
niceoneishereAuthor Commented:
Thanks for the replies, appreciate it
0
 
niceoneishereAuthor Commented:
Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now