Showing posts with label echo. Show all posts
Showing posts with label echo. Show all posts

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."

Tuesday, November 3, 2009

Quiz (redux) & PHP forms, passing variables, .

Update: We encountered some technical difficulty in that Adobe CS4 was not installed fully on 3 machines. We remedied that issue and began work on variables.
In the example below, the line that begins with "$dog" shows you how to assign a mathematical value to a variable. In this case, the value of $dog is two-hundred fifty-seven thousand divided by twelve. In the next line (begins with "echo") we learned how to print the variable.



Quiz today.
Today we are going to finish reviewing the basics of HTML and PHP.
Then we will use a form to pass an HTTP get variable from one page to the next.

Monday, November 2, 2009

Quizzical Expressions...

First thing in class on Tuesday, open your secondpage.php pages to edit!

Gents,
Our quiz class average was 12.4 out of 15.0. Not spectacular for an open-notes quiz. That's a B minus, in case you were wondering. We will attempt to improve our scores on a re-quiz on Tuesday.

Today we reviewed code and prepared for the re-quiz opportunity. Here's a recap of today's code:



The above code produces the following output:

Thursday, October 29, 2009

Today we worked on creating our first PHP scripts. We also presented some notes on dynamic sites and the basics of PHP.
Here's our first script, which we wrote in notepad and saved in our K: drives. We were careful to name the page with a *.php extension.




The output of the above code should look something like this:



We also learned that PHP is a server-side language that is cross-platform, as shown in the diagram below:



Lastly, we learned that PHP stands, depending on whom you ask, for:
a) Hypertext Pre-Processor or...
b) Personal Home Page

PHP is used in over 22 million domains, has great security features, and is specially made to work hand-in-glove with the MySQL database system.
Plus, PHP is totally FREE!