Showing posts with label forms. Show all posts
Showing posts with label forms. Show all posts

Tuesday, February 23, 2010

Make Progress Today

Gentlemen:
Regarding the Cash Register Project,
You should, by now, have the form finished and should be working on Page 2 of the assignment. Page 2 contains all the code.
Remember, the goal is to calculate the bill for the restaurant meal:
Here's a tip (Ha, get it? A "tip?").
OK, Several tips:

discount amount = (mealprice * discount decimal)
Discount decimial means a percentage (i.e., 10%) expressed as a decimal (i.e., 0.10)

bill = (mealprice - discount amount) + tax + tip.

Thursday, February 11, 2010

Data Captcha!

Today we will be finishing up our lesson on capturing data using a php form. We will capture first name and last name and send them to a separate page for processing.
Remember the format for the variables we are capturing.
$_GET['fieldname']

or

$_POST['fieldname']

We will also rename variables today to make them simpler to use.

We will also do a bit of logical processing using an IF statement.

Wednesday, November 4, 2009

Invariably Passing...

Today we are learning to pass a variable from one PHP page to the next. Specifically, we are setting up a straight HTML form on the first page ("formtest.php") and sending the information to a second page ("formdisplay.php") when the user clicks "submit."

We created the the first page (the form, named "formtest.php") in Dreamweaver and used the point-and-click Design view interface to create the form (no coding needed). See form layout below:


Be sure to set the properties for various items as well as detailed below:
  1. To create the form (the form is indicated by the red dotted line), click Insert >> form >> form.
  2. Accept form1 as the name of the form; set the "action" of the form to be formdisplay.php
  3. Set the method to "GET." (see picture below)



  4. To insert the name field, click Insert >> Form >> Text Field. Set "Name" to "name," "Char Width" to 25 and "Max Chars" to 50. Be sure to put the text field INSIDE the form, i.e, the red dotted line.
  5. Insert the submit button: Click Insert >> Form >> Button. Accept the default name, etc. and press OK.
  6. Insert the reset button: Click Insert >> Form >> Button. Accept the defaults. Change the "action" for the button to "Reset form."
  7. Save the page.
Open "formdisplay.php" and enter the following code to display the output of the form from formtest.php:


To test the code, open formtest.php on our class webserver, type a name, and press submit. The name should display on the page called "formdisplay.php."