1 00:00:00,460 --> 00:00:03,970 Let's set the value of these form fields equal to the user data. 2 00:00:05,280 --> 00:00:10,480 Currently we are setting the variables for the form fields after the form post. 3 00:00:10,480 --> 00:00:13,440 That means when we view the form before it's submitted, 4 00:00:13,440 --> 00:00:15,700 those variables won't exist. 5 00:00:15,700 --> 00:00:18,370 So we would need to check if those variables are set 6 00:00:18,370 --> 00:00:21,050 before we could use them in the form value. 7 00:00:21,050 --> 00:00:22,590 But there's another way. 8 00:00:22,590 --> 00:00:26,164 Let's set each of these variables to an empty string at the beginning of our 9 00:00:26,164 --> 00:00:30,094 script, then we know that the variable is set and we can use it even if it's empty. 10 00:00:35,287 --> 00:00:39,740 We can add each of these on one line, putting them all together. 11 00:00:39,740 --> 00:00:44,625 $project_id = $title which equals $date which 12 00:00:44,625 --> 00:00:50,560 equals $time which finally equals our empty string. 13 00:00:50,560 --> 00:00:53,647 Now let's use the variables to update the form field values. 14 00:00:59,051 --> 00:01:01,238 As we explored in the previous course, 15 00:01:01,238 --> 00:01:05,800 it's a good idea to escape output whenever you output user data. 16 00:01:05,800 --> 00:01:08,346 Be sure to check the notes associated with this video for 17 00:01:08,346 --> 00:01:09,763 a more detailed explanation. 18 00:01:10,974 --> 00:01:13,382 We'll use HTML special chars for this. 19 00:01:15,003 --> 00:01:24,490 So our PHP will echo htmlspecialchars, And our title. 20 00:01:26,770 --> 00:01:27,910 Then close our php. 21 00:01:27,910 --> 00:01:30,603 Let's copy that code for $date and $time as well. 22 00:01:39,190 --> 00:01:42,578 We have to do something a little different for our select. 23 00:01:42,578 --> 00:01:46,407 After I select value, let's break this up. 24 00:01:53,273 --> 00:01:57,580 Then we can add a conditional, 25 00:01:57,580 --> 00:02:02,054 if ($project_id == $item 26 00:02:02,054 --> 00:02:09,536 Project_id Then 27 00:02:09,536 --> 00:02:12,440 we're going to echo selected. 28 00:02:16,472 --> 00:02:20,900 Now let's refresh the browser, resubmitting the form data. 29 00:02:20,900 --> 00:02:24,730 This time the fields we already filled out are still complete. 30 00:02:24,730 --> 00:02:30,680 So I can easily choose a project, And submit the form again. 31 00:02:31,750 --> 00:02:35,680 This time we're redirected to the task list where we see our new task.