iii.Add ‘booking reference’ field to the data entry form Modify tma02_data_form.php to provide a labelled text field to accept a string of 9 characters in the data entry form.
iii.Add ‘booking reference’ field to the data entry form
Modify tma02_data_form.php to provide a labelled text field to accept a string of 9 characters in the data entry form.
(5 marks)
Mike wants to also capture the booking reference in the form.
Add a label with the text ‘Booking Reference’ and a corresponding text input field, and feedback element to the data entry form. Note that the input field should have a size limit of 9 characters and must be completed with 9 characters by the user. Mike does not want to capture information other than from customers, so every entry will have a booking reference. When the limit is reached it should stop accepting characters, but no message should be produced. Your new form field should have a suitable and meaningful name attribute and use the same name as its id.
The field value should be empty when the page loads.
If you examine the supplied code carefully and observe how the current labels, fields and feedback are implemented, these will give you a good framework from which you can create the additional label, field and feedback element.
In your solution document, provide your code and a screenshot of the web page showing the updated data entry form. Note that at this point the displayed field will not generate the validation messages that the other fields do.
<?php
// TT284 CRUD APP (TMA02)
// DATA ADD/EDIT FORM
// “require” this file to output a form to add or edit data
// For security, required PHP files should “die” if SAFE_TO_RUN is not defined
if (!defined(‘SAFE_TO_RUN’)) {
// Prevent direct execution – show a warning instead
die(basename(__FILE__) . ‘ cannot be executed directly!’);
}
?>
<div class=”report file”>
Executing: <?php _e(basename(__FILE__)) ?>
</div>
<div class=”report”>
Generating a HTML form to match the columns in the database table
</div>
<?php
// If adding, editing or saving, show the form by default
if ($task == ‘add’ or $task == ‘edit’ or $task == ‘save’) {
$checked = ‘checked’;
} else {
$checked = ”;
}
?>
<input <?php _e($checked) ?> id=”show_form” type=”checkbox” class=”collapser” />
<label for=”show_form”>
Show/Hide: Data entry form
</label>
<form method=”POST” action=”<?php _e($url); ?>” onsubmit=”return validateForm()”>
<input type=”hidden” name=”id” value=”<?php _e($id) ?>” />
<!– TODO: Change these inputs according to the columns you expect –>
<p>
<label for=”firstname”>First name:</label>
<input
type=”text”
id=”firstname”
name=”firstname”
value=”<?php _e($data, “firstname”) ?>”
onchange=”validate(event.target)”
/>
<span id=”feedback_firstname” class=”invalid”>
<?php _e($feedback, “firstname”) ?>
</span>
</p>
<p>
<label for=”lastname”>Last name:</label>
<input
type=”text”
id=”lastname”
name=”lastname”
value=”<?php _e($data, “lastname”) ?>”
onchange=”validate(event.target)”
/>
<span id=”feedback_lastname” class=”invalid”>
<?php _e($feedback, “lastname”) ?>
</span>
</p>
<p>
<label for=”email”>Email:</label>
<input
type=”text”
id=”email”
name=”email”
value=”<?php _e($data, “email”) ?>”
onchange=”validate(event.target)”
/>
<span id=”feedback_email” class=”invalid”>
<?php _e($feedback, “email”) ?>
</span>
</p>
<p>
<label for=”save”>Submit:</label>
<input type=”submit” id=”save” name=”task” value=”save” />
<a class=”cancel” href=”<?php _e($url) ?>”>cancel</a>
</p>
</form>
<div class=”report”>
Completed generating a HTML form to match the columns in the database table
</div>
Expert Answer
OR