Source of: /ADI/more_sessions-withCookies/entry_form.php

<?php
session_start
();
if(empty(
$_SESSION['try']))
 
$_SESSION['try']=0;
?>

<html>
<head>
  <title>entry_form</title>
</head>
<body>
<h1>Phonebook details</h1>
<h2>Fields having a "*" are mandatory</h2>

<?php
printf
("</br>Session ID:  %s \n",session_id());
printf ("</br>Number of tries:  %u \n",$_SESSION['try']);

if(!empty(
$_SESSION['errors']))
   foreach (
$_SESSION['errors'] as $message)
       echo(
"</br> <font color=\"red\"> $message </font>\n");
?>

<form method="post" action="input_validation.php">
<table>
  <tr><td>First Name: *</td><td><input type="text" name="firstname" value="<?= $_SESSION['firstname'] ?>"size=50></td></tr>
  <tr><td>Last Name: *</td><td><input type="text" name="lastname" value="<?= $_SESSION['lastname'?>"size=50></td></tr>
  <tr><td>Phone: *</td><td><input type="text" name="phone" value="<?= $_SESSION['phone'] ?>"size=20></td></tr>
  <tr><td><input type="submit" value="Submit data"> </td></tr>
</table> 
</form>
</body>
</html>