Question: URGENT TASK Task 2: Trip registration (2-trip, 8 pts) We would like to save the data of a new trip that we organise. The task

URGENT TASK

Task 2: Trip registration (2-trip, 8 pts)

We would like to save the data of a new trip that we organise. The task is the server-side validation of an already structurally pre-created form (hence HTML level verification is not sufficient) according to the following conditions.

  • a. (1 pt) The trackname field is required. The distance field is also required and can only be a number.
  • b. (2 pts) The from and to fields are required and they must contain a settlement name that is included in the array $places from the starting file. The two fields cannot match!
  • c. (2 pts) The time field is required and it must be in the format X:XX where the Xs are digits. The highest allowed value before the colon (:) is 7, and the value after it must be less than 60.
  • d. (1 pt) In case of incorrect input, an error message should appear next to the given field, informing about the cause of the error.
  • e. (1 pt) The form placed on the page should keep its state which means that the submitted values should be written back into the fields.
  • f. (1 pt) The div with ID success and its contents should only appear in the generated HTML code if the form was submitted by the user and no errors were found during validation.
index.php
$places = [
'rottk',
'Srvr',
'Smeg',
'Keszthely',
'Tapolca',
'Badacsonytrdemic',
'Nagyvzsony',
'Vrosld',
'Zirc',
'Bodajk',
'Szrliget',
'Dorog',
'Piliscsaba',
'Hvsvlgy',
'Rozlia tglagyr',
'Dobogk',
'Visegrd',
'Nagymaros',
'Ngrd',
'Becske',
'Mtraverebly',
'Mtrahza',
'Sirok',
'Szarvask',
'Putnok',
'Aggtelek',
'Bdvaszilas',
'Boldogkvralja',
'Storaljajhely',
'Hollhza'
];
?>
DOCTYPE html>
html lang="en">
head>
meta charset="UTF-8">
meta http-equiv="X-UA-Compatible" content="IE=edge">
meta name="viewport" content="width=device-width, initial-scale=1.0">
link rel="stylesheet" href="index.css">
title>Task 2title>
head>
body>
h1>Task 2: Trip registrationh1>
form action="index.php" method="get" novalidate>
label for="i1">Track name:label> input type="text" name="trackname" id="i1"> br>
label for="i2">From:label> input type="text" name="from" id="i2"> br>
label for="i3">To:label> input type="text" name="to" id="i3"> br>
label for="i4">Distance:label> input type="text" name="distance" id="i4"> br>
label for="i5">Time:label> input type="text" name="time" id="i5"> br>
button type="submit">Registerbutton>
form>
h2>Hyperlinks for testingh2>
a href="index.php?trackname=&from=&to=&distance=&time=">trackname=&from=&to=&distance=&time=a>br>
a href="index.php?trackname=10.sz.+tra&from=&to=&distance=&time=">trackname=10.sz.+tra&from=&to=&distance=&time=a>br>
a href="index.php?trackname=10.sz.+tra&from=Budapest&to=&distance=&time=">trackname=10.sz.+tra&from=Budapest&to=&distance=&time=a>br>
a href="index.php?trackname=10.sz.+tra&from=Srvr&to=&distance=&time=">trackname=10.sz.+tra&from=Srvr&to=&distance=&time=a>br>
a href="index.php?trackname=10.sz.+tra&from=Srvr&to=Srvr&distance=&time=">trackname=10.sz.+tra&from=Srvr&to=Srvr&distance=&time=a>br>
a href="index.php?trackname=10.sz.+tra&from=Srvr&to=Dobogk&distance=&time=">trackname=10.sz.+tra&from=Srvr&to=Dobogk&distance=&time=a>br>
a href="index.php?trackname=10.sz.+tra&from=Srvr&to=Dobogk&distance=ezer&time=">trackname=10.sz.+tra&from=Srvr&to=Dobogk&distance=ezer&time=a>br>
a href="index.php?trackname=10.sz.+tra&from=Srvr&to=Dobogk&distance=1000&time=">trackname=10.sz.+tra&from=Srvr&to=Dobogk&distance=1000&time=a>br>
a href="index.php?trackname=10.sz.+tra&from=Srvr&to=Dobogk&distance=1000&time=10">trackname=10.sz.+tra&from=Srvr&to=Dobogk&distance=1000&time=10a>br>
a href="index.php?trackname=10.sz.+tra&from=Srvr&to=Dobogk&distance=1000&time=10%3A60">trackname=10.sz.+tra&from=Srvr&to=Dobogk&distance=1000&time=10%3A60a>br>
a href="index.php?trackname=10.sz.+tra&from=Srvr&to=Dobogk&distance=1000&time=4%3A10">span style="color: green">Correct input: span>trackname=10.sz.+tra&from=Srvr&to=Dobogk&distance=1000&time=4%3A10a>br>
body>
html>
 URGENT TASK Task 2: Trip registration (2-trip, 8 pts) We would

TASK 2: TRIP REGISTRATION

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!