Download Document 7760007

yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

User Interaction and Forms
$birthdays['Kevin'] = '1978-04-12';
$birthdays['Stephanie'] = '1980-05-16';
$birthdays['David'] = '1983-09-09';
Now if we want to know Kevin's birthday, we just look it up using the name as
the index:
echo('My birthday is: ' . $birthdays['Kevin']);
This type of array is especially important when it comes to user interaction in
PHP, as we'll see in the next section. I'll also demonstrate other uses of arrays
throughout this book.
User Interaction and Forms
For many applications of PHP, the ability to interact with users who view the
Web page is essential. Veterans of JavaScript tend to think in terms of event
handlers, which let you react directly to the actions of the user — for example,
the movement of the mouse over a link on the page. Server-side scripting languages
such as PHP have a more limited scope when it comes to user interaction. As
PHP code is activated when a page is requested from the server, user interaction
can occur only in a back-and-forth fashion: the user sends requests to the server,
and the server replies with dynamically generated pages.
The key to creating interactivity with PHP is to understand the techniques we
can use to send information about a user's interaction along with his or her request
for a new Web page. PHP makes this fairly easy, as we'll now see.
The simplest method we can use to send information along with a page request
uses the URL query string. If you've ever seen a URL with a question mark following the file name, you've witnessed this technique in use. Let's look at an easy
example. Create a regular HTML file called welcome1.html (no .php file extension
is required, since there will be no PHP code in this file) and insert this link:
<a href="welcome1.php?name=Kevin">Hi, I'm Kevin!</a>
This is a link to a file called welcome1.php, but as well as linking to the file, we're
also passing a variable along with the page request. The variable is passed as part
of the query string, which is the portion of the URL that follows the question
mark. The variable is called name and its value is Kevin. To restate, we have created a link that loads welcome1.php, and informs the PHP code contained in the
file that name equals Kevin.
Document related concepts

Object-relational impedance mismatch wikipedia, lookup

Microsoft SQL Server wikipedia, lookup

Clusterpoint wikipedia, lookup

Open Database Connectivity wikipedia, lookup

Relational model wikipedia, lookup

Database model wikipedia, lookup