PHP Form Exercises and Development Guide
PHP Form Exercises and Development Guide
Price in dinars: ……
1
ISET Sousse / Server-side Development Lotfi Khediri
3. What happens if the user forgets to enter the multiplicand and/or the
multiplier, or make incorrect entries in these fields of
form? Complete the processing script ([Link]) to make it complete.
robust to these problems.
[Link] alternative is to execute the processing only when the form has
has been properly filled out. For this, the form and its processing must
to be grouped in a single PHP script. Write this script ([Link]), which
doit être redirigé sur lui-même (attributactionde la balise<form>), sauf
when all the information is correct (it then executes the processing
- here, the display of the multiplication table).
$personnes = array(
'mdupond'=> array('prenom' => 'Martin', 'nom' => 'Dupond', 'age' => 25, 'ville'
Paris
'jm'=> array('prenom' => 'Jean', 'nom' => 'Martin', 'age' => 20, 'ville' =>
Villetaneuse
'toto'=> array('prenom' => 'Tom', 'nom' => 'Tonge', 'age' => 18, 'ville' =>
Epinay
'arn'=> array('prenom' => 'Arnaud', 'nom' => 'Dupond', 'age' => 33, 'ville' =>
Paris
'email'=> array('prenom'=>'Emilie', 'nom'=>'Ailta', 'age'=>46,
'ville'=>'Villetaneuse'),
'dask' => array('prenom'=>'Damien',
'nom'=>'Askier','age'=>7,'ville'=>'Villetaneuse')
);
1. Call a PHP page by passing a parameter named 'namepseudo' in the URL.
for value one of the pseudonyms of the array $people. Ensure that the
page displays the username and the associated information contained in the table
$persons. Improve the script so that it displays Sorry, your
pseudonym does not appear in the list if the pseudonym is not a key of the
table$people.
2. Create a form allowing the user to enter the nickname to search for
in order to facilitate data entry for the user. Then directly put the form
in the previously created PHP script in order to be able to easily perform
2
ISET Sousse / Server-side Development Lotfi Khediri
4. On the previous page '[Link]', add a button (of type submit) that
Leads to a page '[Link]' that displays a form initialized by the
information about the questioned pseudonym. Write the page '[Link]'.
5. Create a second form asking for a username, a first name, a last name,
an age and a city, and adding a new person in the table$people
where the values are those given by the form. Add multiple people
and then explain the problem. (Display the entire table to better see the
problem.) How to remedy this (answer without code as the knowledge
necessary for the response exceed the scope of this chapter) ?
3
ISET Sousse / Server-side Development Lotfi Khediri
Exercise 5: Calculator
The purpose of this exercise is to create a simple calculator. The user must enter
two numbers and choose an operation among addition, subtraction,
multiplication or division. The result of the operation must then be displayed.
oThe email address contains a single at symbol, ends with '.fr', '.com'
or ".org", the other characters being letters, numbers or the
underscore symbol. In addition, the address must contain at least 3
characters before the at sign and between 4 and 10 characters between the at sign
and the end of the chain.
The PHP script must then indicate whether the input is correct and in that case,
display the entered information.
4
ISET Sousse / Server-side Development Lotfi Khediri
The Guess the Number game is played by a single player. The computer chooses a number
random integer between 1 and 100 inclusive. The player has 7 attempts to
find this number. With each attempt, if the number entered by the user is
different from the random number, the program indicates if the entered number is higher
smaller or larger than the random number.