In Visual Studio Code, I need to be able to enter data into the fields. But if the user hits the submit values button and a field is empty, they get an error message (As in the provided images). The code goes something like this. Week2 GP1 - Michael Porter Enter your name: Enter your date of birth: Enter your favorite color:
In Visual Studio Code, I need to be able to enter data into the fields. But if the user hits the submit values button and a field is empty, they get an error message (As in the provided images). The code goes something like this. Week2 GP1 - Michael Porter Enter your name: Enter your date of birth: Enter your favorite color:
Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%
In Visual Studio Code, I need to be able to enter data into the fields. But if the user hits the submit values button and a field is empty, they get an error message (As in the provided images). The code goes something like this.
<html>
<head>
<title>Week2 GP1 - Michael Porter</title>
</head>
<body>
<form method='POST'>
<h3>Enter your name: <input type="text" name="name"></h3>
<h3>Enter your date of birth: <input type="text" name="birth"></h3>
<h3>Enter your favorite color: <input type="text" name="color"></h3>
<h3>Enter your favorite place to visit: <input type="text" name="fav_place"></h3>
<h3>Enter your Nickname: <input type="text" name="nickname"></h3>
<input type="submit" value="Submit Values">
</form>
<?php
$name = '';
$birth = '';
$color = '';
$fav_place = '';
$nickname = '';
if (isset($_POST['name']))
$first_name = $_POST['name'];
if (isset($_POST['birth']))
$birth = $_POST['birth'];
if (isset($_POST['color']))
$color = $_POST['color'];
if (isset($_POST['fav_place']))
$fav_place = $_POST['fav_place'];
if (isset($_POST['nickname']))
$nickname = $_POST['nickname'];
if (strlen($name) > 0)
echo "<h3> The name you entered is: $name </h3>";
if (strlen($birth) > 0)
echo "<h3> The birthdate you entered is: $birth </h3>";
if (strlen($color) > 0)
echo "<h3> You said your favorite color is: $color </h3>";
if (strlen($fav_place) > 0)
echo "<h3> You said your favorite place is: $fav_place </h3>";
if (strlen($nickname) > 0)
echo "<h3> You said your nickname is: $nickname </h3>";
?>
</body>
</html>
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning