Nota PHP.pdf

download Nota PHP.pdf

of 50

Transcript of Nota PHP.pdf

  • 8/14/2019 Nota PHP.pdf

    1/50

    NOTA PHP

    Menggunakan

    Adobe

    Dreamweaver

    DISEDIAKAN OLEH

    Arif Wahab

  • 8/14/2019 Nota PHP.pdf

    2/50

    INTRODUCTION

    What is PHP

    PHP (recursive acronym for "PHP: Hypertext Preprocessor") is a widely-used Open

    Source general-purpose scripting language that is especially suited for Web developmentand can be embedded into HTML.Simple answer, but what does that mean? An example:

    An introductory example

    Example

  • 8/14/2019 Nota PHP.pdf

    3/50

    What can PHP do

    Anything. PHP is mainly focused on server-side scripting, so you can do anything any

    other CGI program can do, such as collect form data, generate dynamic page content, orsend and receive cookies. But PHP can do much more.

    There are three main areas where PHP scripts are used.

    Server-side scripting. This is the most traditional and main target field for PHP.

    You need three things to make this work. The PHP parser (CGI or server module),

    a webserver and a web browser. You need to run the webserver, with a connectedPHP installation. You can access the PHP program output with a web browser,

    viewing the PHP page through the server. All these can run on your home

    machine if you are just experimenting with PHP programming. See the

    installation instructions section for more information.

    Command line scripting. You can make a PHP script to run it without any server

    or browser. You only need the PHP parser to use it this way. This type of usage isideal for scripts regularly executed using cron (on *nix or Linux) or Task

    Scheduler (on Windows). These scripts can also be used for simple textprocessing tasks. See the section about Command line usage of PHP for moreinformation.

    Writing desktop applications. PHP is probably not the very best language to

    create a desktop application with a graphical user interface, but if you know PHPvery well, and would like to use some advanced PHP features in your client-side

    applications you can also use PHP-GTK to write such programs. You also have

    the ability to write cross-platform applications this way. PHP-GTK is an

    extension to PHP, not available in the main distribution. If you are interested inPHP-GTK, visit its own website.

    PHP can be used on all major operating systems, including Linux, many Unix variants(including HP-UX, Solaris and OpenBSD), Microsoft Windows, Mac OS X, RISC OS,

    and probably others. PHP has also support for most of the web servers today. This

    includes Apache, Microsoft Internet Information Server, Personal Web Server, Netscapeand iPlanet servers, Oreilly Website Pro server, Caudium, Xitami, OmniHTTPd, and

    many others. For the majority of the servers PHP has a module, for the others supporting

    the CGI standard, PHP can work as a CGI processor.

    So with PHP, you have the freedom of choosing an operating system and a web server.Furthermore, you also have the choice of using procedural programming or object

    oriented programming, or a mixture of them. Although not every standard OOP feature is

    implemented in PHP 4, many code libraries and large applications (including the PEARlibrary) are written only using OOP code. PHP 5 fixes the OOP related weaknesses of

    PHP 4, and introduces a complete object model.

  • 8/14/2019 Nota PHP.pdf

    4/50

    With PHP you are not limited to output HTML. PHP's abilities includes outputtingimages, PDF files and even Flash movies (using libswf and Ming) generated on the fly.

    You can also output easily any text, such as XHTML and any other XML file. PHP can

    autogenerate these files, and save them in the file system, instead of printing it out,forming a server-side cache for your dynamic content.

    One of the strongest and most significant features in PHP is its support for a wide rangeof databases. Writing a database-enabled web page is incredibly simple. The following

    databases are currently supported:

    Adabas D InterBase PostgreSQL

    DBase FrontBase SQLite

    Empress mSQL Solid

    FilePro (read-only) Direct MS-SQL Sybase

    Hyperwave MySQL Velocis

    IBM DB2 ODBC Unix dbm

    Informix Oracle (OCI7 and OCI8)

    Ingres Ovrimos

    We also have a DBX database abstraction extension allowing you to transparently useany database supported by that extension. Additionally PHP supports ODBC, the Open

    Database Connection standard, so you can connect to any other database supporting this

    world standard.

    PHP also has support for talking to other services using protocols such as LDAP, IMAP,

    SNMP, NNTP, POP3, HTTP, COM (on Windows) and countless others. You can alsoopen raw network sockets and interact using any other protocol. PHP has support for theWDDX complex data exchange between virtually all Web programming languages.

    Talking about interconnection, PHP has support for instantiation of Java objects and

    using them transparently as PHP objects. You can also use our CORBA extension to

    access remote objects.

    PHP has extremely useful text processing features, from the POSIX Extended or Perl

    regular expressions to parsing XML documents. For parsing and accessing XMLdocuments, PHP 4 supports the SAX and DOM standards, and you can also use the

    XSLT extension to transform XML documents. PHP 5 standardizes all the XML

    extensions on the solid base of libxml2 and extends the feature set adding SimpleXMLand XMLReader support.

    While using PHP in the e-commerce field, you'll find the Cybercash payment,

    CyberMUT, VeriSign Payflow Pro and MCVE functions useful for your online paymentprograms.

  • 8/14/2019 Nota PHP.pdf

    5/50

    At last but not least, we have many other interesting extensions, the mnoGoSearch searchengine functions, the IRC Gateway functions, many compression utilities (gzip, bz2),

    calendar conversion, translation...

    As you can see this page is not enough to list all the features and benefits PHP can offer.Read on in the sections about installing PHP, and see the function reference part for

    explanation of the extensions mentioned here.

    What you need to build web applications

    To build web applications in Dreamweaver, you need the following software:

    A web server

    An application server that runs on your web server, or a web server that doubles

    as an application server, such as APACHE

    Note: In the context of web applications, the terms webserverand application serverrefer to software, not hardware.

    If you want to use a database with your application, you need the following additional

    software:

    A database or database system

    A database driver that supports your database

    How Web Servers Work

  • 8/14/2019 Nota PHP.pdf

    6/50

    PART 1: Installing WAMPWINDOWS, APACHE, MYSQL AND PHP

    Introduction

    WAMP5 is an installer for Windows. it installs a complete WAMP solution on yourcomputer. WAMP is for :

    Windows - Apache - MySQL- PHP5

    WAMP5 automatically configures them to work together, wherever you install them on

    your local drive.

    These softwares are installed:

    Apache 2.2.x.

    PHP 5.x.xMySQL 5.x.xPHPmyadmin

    SQLitemanager

    Wampserver service manager

    WAMP5 comes with a service manager as an icon tray. This manager will allow you to

    fully control your server and local projects.

    WAMP5 is not designed for production but as a development environment. With

    WAMP5, you will be able to create you scripts locally on your computer, test them and

    then upload them on your production server.

    We have configured Apache and MySQL servers with default configuration files to have

    the most standard platform. You can then adapt it to your personal needs.

    During installation, a "www" directory is created in WAMP5's directory. Just put your

    script files (php files) in this directory and access your localhost threw an Internet

    Windows or the service manager (icon tray).

    WAMP5 requires one of these systems to work:

    Windows XP, NT, 2000, 2003

    How To Install

    Download the latest release of WAMP5 on one of the WAMPSERVER sites:

    http://www.wampserver.com/en/

    http://www.wampserver.com/en/http://www.wampserver.com/en/http://www.wampserver.com/en/
  • 8/14/2019 Nota PHP.pdf

    7/50

    Double-click on the file to start installing.

    WAMP5 will ask you where to install. You can install wherever you want, WAMP5

    builds configuration files to reflect your choice. But don't forget that some scripts andmodules don't like long names and special characters like spaces.

    Process of Installation

    1. Click -> NEXT

    2. Click -> I accept the agreement

    3. Click -> Next

  • 8/14/2019 Nota PHP.pdf

    8/50

    4. Click Next(*Recommended you to leave default directory c:\wamp)

    5. Click Next

    (*Recommended you to leave the default)

  • 8/14/2019 Nota PHP.pdf

    9/50

    WAMP5 will then ask you if want to install the option "Auto Start". If you check this

    option, services will be installed as automatic and a link to the service manager will becopied to your startup menu. Otherwise, services will be installed as manual and will start

    and stop with the service manager.

    6. Click auto start checkbox to make the services are autostart.7. Click Next

    (*Recommended you to click the auto start)

    8. Click Install

  • 8/14/2019 Nota PHP.pdf

    10/50

    Installing. Wait until finish.

    9. Click Next

    (*Recommended you to leave the default)

  • 8/14/2019 Nota PHP.pdf

    11/50

    10. Click Open

    (*Recommended you to leave the default)

    11. Click Yes

    12. Click Finish

    Installation finish

  • 8/14/2019 Nota PHP.pdf

    12/50

    After installation.

    WAMP5's installation is compact. This means that all files are copied to WAMP5's

    directory. Only the MySQL conf file (usually my.ini) is copied to the Windows directorybut as "mywamp.ini" to avoid conflicts with other installs

    You just have to click on the icon tray to access WAMP5's menu :

  • 8/14/2019 Nota PHP.pdf

    13/50

    The icon tray reflects the status of your server :

  • 8/14/2019 Nota PHP.pdf

    14/50

    PART 2: DATABASE

    SQLYOG

    Introduction

    SQLyogprovides you with powerful means to manage your MySQL databases. SQLyogMySQL GUI is the most popular MySQL Manager and MySQL Admin Tool, combining

    the features of MySQL Query Browser, phpMyAdmin and various other MySQL FrontEnds and MySQL Clients in a single intuitive interface.

    Installing SQLyog

    Download the latest version of SQLyog and click the setup file.

    1. Click Next

  • 8/14/2019 Nota PHP.pdf

    15/50

    2. Click I accept the terms in the license agreement3. Click Next

    4. Click Next

    (*Recommended you to leave the default)

  • 8/14/2019 Nota PHP.pdf

    16/50

  • 8/14/2019 Nota PHP.pdf

    17/50

    Starting SQLyog

    Run SQLyog and you will see dialog box as shown below:

    After you have connected to an instance of MySQL, you can make additional connections

    by selecting the New Connection option from the File menu.

    Saved Connections

    Select the connection name from the list. To Change the

    connection, click on the ellipsis button and edit the connectionname, click OK button to save the changed connection name.

    MySQL host

    address

    A host name where the database is situated or the IP address ofthe server.

    User nameUser name for connecting to the database server. Note: This isMySQL username. Not your FTP or webserver username.

    Password MySQL user Password

    DatabasesDatabase name. You may enter several database names separatedby semicolon (like db1,db2). If you do not enter the databasename, all the database names would be listed, to select from.

    Port A TCP/IP port for connecting to the database server.

  • 8/14/2019 Nota PHP.pdf

    18/50

    MySQL Database

    1. Intoduction

    MySQL is a database. A database is a data storage feature. It can be used to store, sort,

    arrange, and display information. MySQL is a functional feature on it's own. For ourtutorials, we will be using PHP commands to use the functions of a MySQL database.

    2. Reserved Words

    Before getting to far into planning, there is a number of words that you cannot use for

    your table and column names. MySQL uses some specific words for command

    processing, so using them in your own coding may confuse things a bit.

    See appendix MySQL-1.

    3. Data Type in MySQL

    Once you have your table data organized, the next step is to figure out the data type.

    There are three main types : text, numbers, and Dates/Times. Choosing the column

    types specifies what information can or can't be stored in a table cell. Using the mostcorrect option for each column is important as it may affect the database's overall

    performance.

    3.1 Text Types

    CHAR( ) A fixed section from 0 to 255 characters long.

    VARCHAR( ) A variable section from 0 to 255 characters long.TINYTEXT A string with a maximum length of 255 characters.

    TEXT A string with a maximum length of 65535 characters.

    BLOB A string with a maximum length of 65535 characters.

    MEDIUMTEXT A string with a maximum length of 16777215 characters.

    MEDIUMBLOB A string with a maximum length of 16777215 characters.

    LONGTEXT A string with a maximum length of 4294967295 characters.

    LONGBLOB A string with a maximum length of 4294967295 characters.

    The ( ) brackets allow you to enter a maximum number of characters will be used in thecolumn.

    Eg. VARCHAR(20)

    CHAR and VARCHAR are the most widely used types. CHAR is a fixed length stringand is mainly used when the data is not going to vary much in it's length. VARCHAR is a

    variable length string and is mainly used when the data may vary in length.

    CHAR may be faster for the database to process considering the fields stay the same

    length down the column. VARCHAR may be a bit slower as it calculates each field down

  • 8/14/2019 Nota PHP.pdf

    19/50

    the column, but it saves on memory space. Which one to ultimatly use is up to you.

    Using both a CHAR and VARCHAR option in the same table, MySQL will

    automatically change the CHAR into VARCHAR for compatability reasons.

    BLOB stands for Binary Large OBject. Both TEXT and BLOB are variable length typesthat store large amounts of data. They are similar to a larger version of VARCHAR.These types can store a large piece of data information, but they are also processed much

    slower.

    3.2 Number Types

    TINYINT( ) -128 to 127 normal 0 to 255 UNSIGNED.

    SMALLINT( ) -32768 to 32767 normal 0 to 65535 UNSIGNED.

    MEDIUMINT( ) -8388608 to 8388607 normal 0 to 16777215 UNSIGNED.

    INT( ) -2147483648 to 2147483647 normal 0 to 4294967295 UNSIGNED.

    BIGINT( ) -9223372036854775808 to 9223372036854775807 normal 0 to18446744073709551615 UNSIGNED.

    FLOAT A small number with a floating decimal point.

    DOUBLE( , ) A large number with a floating decimal point.

    DECIMAL( , ) A DOUBLE stored as a string , allowing for a fixed decimal point.

    The integer types have an extra option called UNSIGNED. Normally, the integer goes

    from an negative to positive value. Using an UNSIGNED command will move that rangeup so it starts at zero instead of a negative number.

    3.3 Date Types

    DATE YYYY-MM-DD.

    DATETIME YYYY-MM-DD HH:MM:SS.

    TIMESTAMP YYYYMMDDHHMMSS.

    TIME HH:MM:SS.

    3.4 Misc Types

    ENUM ( )Short for ENUMERATION which means that each column may

    have one of a specified possible values.

    SETSimilar to ENUM except each column may have more than one ofthe specified possible values.

    ENUM is short for ENUMERATED list. This column can only store one of the valuesthat are declared in the specified list contained in the ( ) brackets.

    Eg. ENUM('y','n')

  • 8/14/2019 Nota PHP.pdf

    20/50

    You can list up to 65535 values in an ENUM list. If a value is inserted that is not in thelist, a blank value will be inserted.

    SET is similar to ENUM except SET may contain up to 64 list items and can store more

    than one choice.

    4. Column Modifier

    A column modifier is an extra addon command to help the database organize and workbetter.

    As mentioned on the previous page, the integer types have an extra option called

    UNSIGNED. Normally, the integer goes from an negative to positive value. Using anUNSIGNED command will move that range up so it starts at zero instead of a negative

    number.

    Other modifier commands are : INDEX, UNIQUE, PRIMARY KEY,

    AUTO_INCREMENT, NULL, NOT NULL, DEFAULT, BINARY, and ZEROFILL.

    4.1 Index

    Indexing is a way to improve a database performance. You are telling the database that

    THIS specific column is special and may help organize the data. If there is a column youwill be referring to often, it would probably be the best to be an INDEX column.

    4.2 Unique and Primary Key

    An INDEX column may have more than one cell holding the same data value. The two

    other index types are UNIQUE and PRIMARY KEY. UNIQUE states that each cell in

    the column should have a unique value. PRIMARY KEY is a special variety of the

    UNIQUE command.

    4.3 Auto Increment

    The AUTO_INCREMENT modifier works on any of the integer types. Each time a new

    row is added into the database table, the number in this column will appear and

    automatically increase by one from the previous row.

    4.4 Null

    NULL is no value. It is not space, it is not zero. A majority of the time you will want tospecify a field to be NOT NULL so that any blank entries will be considered as

    "something".

  • 8/14/2019 Nota PHP.pdf

    21/50

    4.5 Default

    DEFAULT will assign a default value to a cell if nothing is entered for the value. It will

    work on most data types except BLOB and TEXT.

    4.6 Binary

    BINARY is used with CHAR and VARCHAR types. It causes the values to be treated as

    "binary strings" making them CaSe SeNsItIvE.

    4.7 Zerofill

    ZEROFILL is used with numeric data types. It will display leading zeros of a number

    based on the display width.

    5.0 Table Type

    5.1 MySQL Architecture

    It will greatly aid your thinking about storage engines and the capabilities they bring to

    MySQL if you have a good mental picture of where they fit. Figure 2-1 provides a logicalview of MySQL. It doesnt necessarily reflect the low-level implementation, which is

    bound to be more complicated and less clear cut. However, it does serve as a guide that

    will help you understand how storage engines fit in to MySQL. (The NDB storage enginewas added to MySQL just before this book was printed. Watch for it in the second

    edition.)

  • 8/14/2019 Nota PHP.pdf

    22/50

  • 8/14/2019 Nota PHP.pdf

    23/50

    index, reuse of values deleted from the top of a sequence does occur.) TheAUTO_INCREMENT value can be reset with ALTER TABLE or myisamchk.

    Dynamic-sized rows are much less fragmented when mixing deletes with updates

    and inserts. This is done by automatically combining adjacent deleted blocks andby extending blocks if the next block is deleted.

    If a table has no free blocks in the middle of the data file, you can INSERT newrows into it at the same time that other threads are reading from the table. (Theseare known as concurrent inserts.) A free block can occur as a result of deleting

    rows or an update of a dynamic length row with more data than its current

    contents. When all free blocks are used up (filled in), future inserts become

    concurrent again..

    You can put the data file and index file on different directories to get more speed

    with the DATA DIRECTORY and INDEX DIRECTORY table options to

    CREATE TABLE.

    BLOB and TEXT columns can be indexed.

    NULL values are allowed in indexed columns. This takes 01 bytes per key.

    Each character column can have a different character set. .

    There is a flag in the MyISAM index file that indicates whether the table wasclosed correctly. If mysqld is started with the --myisam-recover option, MyISAM

    tables are automatically checked when opened, and are repaired if the table wasn't

    closed properly.

    MyISAM also supports the following features:

    Support for a true VARCHAR type; a VARCHAR column starts with a lengthstored in one or two bytes.

    Tables with VARCHAR columns may have fixed or dynamic row length. The sum of the lengths of the VARCHAR and CHAR columns in a table may be

    up to 64KB.

    5.3 InnoDB

    InnoDB provides MySQL with a transaction-safe (ACID compliant) storage engine that

    has commit, rollback, and crash recovery capabilities. InnoDB does locking on the row

    level and also provides an Oracle-style consistent non-locking read in SELECTstatements. These features increase multi-user concurrency and performance. There is no

    need for lock escalation in InnoDB because row-level locks fit in very little space.

    InnoDB also supports FOREIGN KEY constraints. You can freely mix InnoDB tables

    with tables from other MySQL storage engines, even within the same statement.

    InnoDB has been designed for maximum performance when processing large data

    volumes. Its CPU efficiency is probably not matched by any other disk-based relational

    database engine.

  • 8/14/2019 Nota PHP.pdf

    24/50

    Fully integrated with MySQL Server, the InnoDB storage engine maintains its ownbuffer pool for caching data and indexes in main memory. InnoDB stores its tables and

    indexes in a tablespace, which may consist of several files (or raw disk partitions). This is

    different from, for example, MyISAM tables where each table is stored using separatefiles. InnoDB tables can be of any size even on operating systems where file size is

    limited to 2GB.

    InnoDB is included in binary distributions by default. The Windows Essentials installer

    makes InnoDB the MySQL default storage engine on Windows.

    InnoDB is used in production at numerous large database sites requiring high

    performance. The famous Internet news site Slashdot.org runs on InnoDB. Mytrix, Inc.

    stores over 1TB of data in InnoDB, and another site handles an average load of 800

    inserts/updates per second in InnoDB.

    Creating Database and Table in SQLyog

    Database name: student

    Table name: std_info

    Engine: MyISAMFields:

    Fields_Name Datatype Len Default Other

    std_name varchar 100 NOT NULL

    std_id double 0 PK, NOT NULL

    std_address text NOT NULL

    std_phone_h varchar 15

    std_phone_hp varchar 15

    std_gender enum Male,Female Male NOT NULLstd_origin varchar 15 NOT NULL

  • 8/14/2019 Nota PHP.pdf

    25/50

    PART 3: ADOBE DREAMWEAVER

    1. Defining Site

    Organizing the site structure

    Break down your site into categories

    Decide where to put items such as images and sound files

    Use the same structure for local and remote sites

    Setting up a Dreamweaver site

    A Dreamweaver site consists of as many as three parts, depending on your environment

    and the type of website you are developing:

    Local folder is your working directory. Dreamweaver refers to this folder as your

    localsite. Remote folder is where you store your files, depending on your environment, for

    testing, production, collaboration, or so on. Dreamweaver refers to this folder as

    your remote site

    Folder for dynamic pages is the folder where Dreamweaver processes dynamicpages.

    To set up a Dreamweaver site:

    1. Select Site > New Site.

    The Site Definition dialog box appears.

    2. Click the Basic tab to use the Site Definition Wizard, or click the Advanced tab to

    use the Advanced settings.

    Note: Users who are new to Dreamweaver are encouraged to use the Site Definition

    Wizard; experienced Dreamweaver users might prefer to use the Advanced settings.

  • 8/14/2019 Nota PHP.pdf

    26/50

    Setting Up Local Folder

    Setting Up Testing Server

  • 8/14/2019 Nota PHP.pdf

    27/50

  • 8/14/2019 Nota PHP.pdf

    28/50

    Creating Interactive Forms

    Client-side role of forms

    Forms support the client side of the client-server relationship. When a visitor enters

    information into a form displayed in a web browser (the client) and clicks the submitbutton, the information is sent to the server where a server-side script or application

    processes it. Common server-side technologies used for processing form data include

    Macromedia ColdFusion, Microsoft Active Server Pages (ASP), and PHP. The serverresponds by sending requested information back to the user (or client), or performing

    some action based on the forms contents.

    Forms allow you to interact with or gather information from visitors to a website. Forms

    collect information from the user and submit this information to the server for processing.Forms can contain various objects that enable user interaction. These form objects

    include text fields, list boxes, check boxes, and radio buttons. The form tag includes

    parameters that let you specify a path to the server-side script or application that willprocess the form data, and which HTTP method to use when transmitting data from the

    browser to the server.

    About form objects

    In Dreamweaver, form input types are called form objects. You can insert form objectsby choosing Insert > Form Objects, or by accessing the form objects from the Forms

    panel of the Insert bar shown below.

  • 8/14/2019 Nota PHP.pdf

    29/50

    The Forms bar provides the following buttons:

    Form

    Inserts a form in the document. Dreamweaver inserts opening and closing form tags in

    the HTML source code. Any additional form objects, such as text fields, buttons, and so

    on must be inserted between the form tags for the data to be processed correctly by all

    browsers.

    *In the Method pop-up menu, choose the method that will transmit the form data to theserver. The form Methods are:

    POST Embeds the form data in the HTTP request.

    GET Appends the value to the URL requesting the page.

    Default Uses the browsers default setting to send the form data to the server.Typically the default is the GET method.

    Do not use the GET method to send long forms. URLs are limited to 8,192 characters. If

    the amount of data sent is too large, data will be truncated, leading to unexpected or

    failed processing results. Also, do not use GET method when sending confidential usernames and password, credit card numbers, or other confidential information. GET is not a

    secure method for passing information.

    Text Field & Text Area

    Inserts a text field in a form. Text fields accept any type of alphanumeric entries.The entered text can be displayed as a single line, as multiple lines, or as bullets or

    asterisks (for password protection).

    Single-line text fields typically provide a single word or short phrase response,such as a name, or an address.

    Multiple-line text fieldsprovide the visitor with a larger area in which to enter aresponse. You can specify the maximum number of lines the visitor can enter, and the

  • 8/14/2019 Nota PHP.pdf

    30/50

    character width of the object. If text is entered that exceeds these settings, the field willscroll, following the setting specified in the wrap attribute.

    Password fields are a special type of text field. When a user types in a passwordfield, the entered text is replaced by asterisks or bullets to obscure the text, and protect

    the information from being viewed.

    Hidden Field

    Inserts a field in the document in which user data can be stored. Hidden fields let youstore information entered by a user, such as a name, e-mail address, or purchase

    preference, and then use that data when the user next visits the site.

    Check Box

    Inserts a check box in a form. Check boxes allow multiple responses in a single group of

    options, a user can select as many options as apply.

    Radio Button

    Inserts a radio button in a form. Radio buttons represent exclusive choices. Selecting abutton within a group deselects all others in the group. For example a user can select Yes

    or No.

  • 8/14/2019 Nota PHP.pdf

    31/50

    Radio Group

    Inserts a collection of radio buttons which share the same name.

    Understanding checkboxes and radio buttonsCheck boxes toggle each individual response off and on. Thus, a user can select morethan one option from a checkbox group. The example below illustrates this by showing

    three checkbox items selected: Surfing, Mountain Biking, and Rafting.

    Radio buttons work as a group and provide mutually exclusive selection values. A user

    can select only one option within a radio button group. In the example below, Raftingis the currently selected option. If the user were to click Surfing, the Raftingbutton

    would be automatically deselected.

  • 8/14/2019 Nota PHP.pdf

    32/50

    List/Menus

    Allows you to create user choices in a list. The List option displays the option values in a

    scrolling list and allows users to select multiple options in the list. The Menu option

    displays the option values in a pop-up menu and allows users to select only a singlechoice.

    Jump Menu

    Inserts a navigational list or pop-up menu. Jump menus let you insert a menu in which

    each option links to a document or file

    Image Field

    Allows you to insert an image in a form. Image fields can be used in place of Submit

    buttons to make graphical buttons.

    File Field

    Inserts a blank text field and a Browse button in a document. File fields let users browse

    to files on their hard disks and upload the files as form data.

    Button

    Inserts a text button within a form. Buttons perform tasks when clicked, such assubmitting or resetting forms. You can add a custom name or label to a button, or use one

    of the predefined Submit or Reset labels.

  • 8/14/2019 Nota PHP.pdf

    33/50

    Exercise :

    Create a Form as shown below (textfield, textarea, radio button,

    list/menu, buttons and table) save as student_reg.php

    Make sure the name for each form objects are same with field name. You can change the

    name by selecting the form object and go to Properties Panel.

    Text Field: Name

    Create new file name congra_saving.php. The content of the file is

    shown below.

  • 8/14/2019 Nota PHP.pdf

    34/50

  • 8/14/2019 Nota PHP.pdf

    35/50

    1. Choose Connection.2. Choose Insert table.

    3. Make sure in Columns all values are assigned to field name.4. Click button Browse and choose file congra_saving.php.

    5. Click button OK.

    6. In Application > Server Behaviors the Insert Behavior will be added.

    To make any changes, just click the behavior and you will get Insert Record dialog boxagain.

    Validate Form

    The Validate Form action checks the contents of specified text fields to ensure that the

    user has entered the correct type of data. Attach this action to individual text fields with

    the onBlur event to validate the fields as the user is filling out the form, or attach it to theform with the onSubmit event to evaluate several text fields at once when the user clicks

    the Submit button. Attaching this action to a form prevents the form from beingsubmitted to the server if any of the specified text fields contains invalid data.

  • 8/14/2019 Nota PHP.pdf

    36/50

    To use the Validate Form action in registration.php

    1. Do one of the following:

    o To validate individual fields as the user fills out the form, select a text

    field and select Window > Behaviors.

    o

    To validate multiple fields when the user submits the form, click the tag in the tag selector in the bottom left corner of the Documentwindow and select Window > Behaviors.

    2. Select Validate Form from the Actions pop-up menu.

    3. Do one of the following:

    o If you are validating individual fields, select the same field that you have

    selected in the Document window from the Named Fields list.

    o If you are validating multiple fields, select a text field from theNamed Fields list.

    4. Select the Required option if the field must contain some data.

    5. Select from one of the following Accept options:

    Use Anything if the field is required but need not contain any particular kind of

    data. (If the Required option is not selected, the Anything option is meaningless--

    that is, it is the same as if the Validate Form action were not attached to the field.)

    Use E-mail address to check that the field contains an @ symbol.

    Use Number to check that the field contains only numerals.

    Use Number From to check that the field contains a number in a specific range.

    6. If you are validating multiple fields, repeat steps 3 and 4 for any additional fieldsthat you want to validate.

    7. Click OK.

    If you are validating multiple fields when the user submits the form, the onSubmit

    event automatically appears in the Events pop-up menu.

    8. If you are validating individual fields, check that the default event is onBlur

    or onChange.

    If it isnt,select onBlur or onChange from the pop-up menu. Both of these events

    trigger the Validate Form action when the user moves away from the field. The

    difference between them is that onBlur occurs whether or not the user has typed in

    the field, and onChange occurs only if the user changed the contents of the field.The onBlur event is preferred when you have specified that the field is required.

  • 8/14/2019 Nota PHP.pdf

    37/50

  • 8/14/2019 Nota PHP.pdf

    38/50

    Recordset (Query)

    Now youll create a recordset to select the data you want to display. A recordset is a

    subset of information extracted from a database by a database query. A database query

    consists of search criteria, which defines whats included in the recordset. You then use

    the information extracted as a source of content for your dynamic pages.

    To open recordset:

    Click recordset in Server Behaviors and the below recordset will appear.

    Enter the name (rsstudent)

    Click Test to test the recordset

    Click OK to close the Test SQL Statement window. Click OK to close the Recordset or DataSet dialog box.

  • 8/14/2019 Nota PHP.pdf

    39/50

  • 8/14/2019 Nota PHP.pdf

    40/50

    RepeatingRegion

    Lets you repeat a region but doesnt include an editable region. However, you can insertan editable region in a repeating region to make it editable.

    After you have added a recordset to a page, and have created a navigation bar, you mustapply individual server behaviors to each navigation element. For example, a typicalrecordset navigation bar contains representations of the following links matched to the

    appropriate behavior:

    Recordset Paging

    Navigation link Server behavior

    Go to first page Move to first page

    Go to the previous page Move to previous page

    Go to the next page Move to next page

    Go to the last page Move to last page

    To assign server behaviors to record navigation links:

    1. In Design view, select the text string or image on the page you want to use as arecord navigation link.

    2. Open the Server Behaviors panel (Window > Server Behaviors) and click the plus

    (+) button.3. Choose Recordset Paging from the pop-up menu, then select a server behavior

    appropriate to that link from the listed server behaviors.

    Note that if the recordset contains a large number of records, the Move to Last

    Record server behavior can take a long time to run when the user clicks the link.

    4. In the Recordset pop-up menu, select the recordset containing the records.

    5. Click OK.

    Show Region

    The Show Region server behaviors are:

    Show If Recordset Is Empty

    Show If Recordset Is Not Empty

    Show If First Page

    Show If Not First Page

    Show If Last Page

  • 8/14/2019 Nota PHP.pdf

    41/50

    Show If not Last Page

    To show a region only when its needed:

    1. In Design view, select the region on the page to show or hide.

    2. In the Server Behaviors panel (Window > Server Behaviors), click theplus (+) button.

    3. Choose Show Region from the pop-up menu, then choose one of the listed serverbehaviors.

    4. Click OK.

    Filtering Record Set (Query)

  • 8/14/2019 Nota PHP.pdf

    42/50

    # Update and Delete will be used when to update and delete the informations of the

    student

    To link page student_list and student_detail.php do as following:

    1. Highlight {rsStudent.std_name} and right click mouse and choose Make Link.

    The dialog box as shown as below.

    2. Choose student_detail.php and click Paratemters button.

  • 8/14/2019 Nota PHP.pdf

    43/50

  • 8/14/2019 Nota PHP.pdf

    44/50

    Update Page

    Before update please make sure you have done this:

    1. Create cong_update.htm page.2. Create Form as shown below.

    Save as student_update.asp

    3. Create recordset with id as a filter.

    4. Select Update Record in Server Behavior Panel.

  • 8/14/2019 Nota PHP.pdf

    45/50

  • 8/14/2019 Nota PHP.pdf

    46/50

    Delete Page

    Before delete please make sure you have done this:

    1. Create cong_delete.htm page.

    2. Create Form as shown below.Save as student_delete.asp

    3. Create recordset with id as a filter.

  • 8/14/2019 Nota PHP.pdf

    47/50

    4. Open the page in Design view, then choose Insert > Application Objects > Delete

    Record Form.

    The Delete Record Form dialog box appears.

    5. Complete the dialog box.

    6. Click OK.

  • 8/14/2019 Nota PHP.pdf

    48/50

    Log In User

    Before log in please make sure you have done this:

    1. Create menu.php page.2. Create sorry.php page.3. Create Form as shown below.

    Save as index.php

    4. Open the page in Design view, then choose Server Behavior > Application

    Objects > User Authentication > Log In User.

    The Log In User Form dialog box appears.

    5. Complete the dialog box.

    6. Click OK.

  • 8/14/2019 Nota PHP.pdf

    49/50

    APPENDIX

    MySQL1: Reserved Words

    ADD ALL ALTERANALYZE AND AS

    ASC ASENSITIVE AUTO_INCREMENT

    BDB BEFORE BERKELEYDB

    BETWEEN BIGINT BINARY

    BLOB BOTH BY

    CALL CASCADE CASE

    CHANGE CHAR CHARACTER

    CHECK COLLATE COLUMN

    COLUMNS CONDITION CONNECTION

    CONSTRAINT CONTINUE CREATE

    CROSS CURRENT_DATE CURRENT_TIMECURRENT_TIMESTAMP CURSOR DATABASE

    DATABASES DAY_HOUR DAY_MICROSECOND

    DAY_MINUTE DAY_SECOND DEC

    DECIMAL DECLARE DEFAULT

    DELAYED DELETE DESC

    DESCRIBE DETERMINISTIC DISTINCT

    DISTINCTROW DIV DOUBLE

    DROP ELSE ELSEIF

    ENCLOSED ESCAPED EXISTS

    EXIT EXPLAIN FALSE

    FETCH FIELDS FLOAT

    FOR FORCE FOREIGN

    FOUND FRAC_SECOND FROM

    FULLTEXT GRANT GROUP

    HAVING HIGH_PRIORITY HOUR_MICROSECOND

    HOUR_MINUTE HOUR_SECOND IF

    IGNORE IN INDEX

    INFILE INNER INNODB

    INOUT INSENSITIVE INSERT

    INT INTEGER INTERVAL

    INTO IO_THREAD ISITERATE JOIN KEY

    KEYS KILL LEADING

    LEAVE LEFT LIKE

    LIMIT LINES LOAD

    LOCALTIME LOCALTIMESTAMP LOCK

    LONG LONGBLOB LONGTEXT

    LOOP LOW_PRIORITY MASTER_SERVER_ID

  • 8/14/2019 Nota PHP.pdf

    50/50

    MATCH MEDIUMBLOB MEDIUMINT

    MEDIUMTEXT MIDDLEINT MINUTE_MICROSECOND

    MINUTE_SECOND MOD NATURAL

    NOT NO_WRITE_TO_BINLOG NULL

    NUMERIC ON OPTIMIZE

    OPTION OPTIONALLY ORORDER OUT OUTER

    OUTFILE PRECISION PRIMARY

    PRIVILEGES PROCEDURE PURGE

    READ REAL REFERENCES

    REGEXP RENAME REPEAT

    REPLACE REQUIRE RESTRICT

    RETURN REVOKE RIGHT

    RLIKE SECOND_MICROSECOND SELECT

    SENSITIVE SEPARATOR SET

    SHOW SMALLINT SOME

    SONAME SPATIAL SPECIFICSQL SQLEXCEPTION SQLSTATE

    SQLWARNING SQL_BIG_RESULT SQL_CALC_FOUND_ROWS

    SQL_SMALL_RESULT SQL_TSI_DAY SQL_TSI_FRAC_SECOND

    SQL_TSI_HOUR SQL_TSI_MINUTE SQL_TSI_MONTH

    SQL_TSI_QUARTER SQL_TSI_SECOND SQL_TSI_WEEK

    SQL_TSI_YEAR SSL STARTING

    STRAIGHT_JOIN STRIPED TABLE

    TABLES TERMINATED THEN

    TIMESTAMPADD TIMESTAMPDIFF TINYBLOB

    TINYINT TINYTEXT TO

    TRAILING TRUE UNDO

    UNION UNIQUE UNLOCK

    UNSIGNED UPDATE USAGE

    USE USER_RESOURCES USING

    UTC_DATE UTC_TIME UTC_TIMESTAMP

    VALUES VARBINARY VARCHAR

    VARCHARACTER VARYING WHEN

    WHERE WHILE WITH

    WRITE XOR YEAR_MONTH

    ZEROFILL