1st is HTML page to ask for few inputs from user (with appropriate validations/c
ID: 3917249 • Letter: 1
Question
1st is HTML page to ask for few inputs from user (with appropriate validations/checks) and send to server with method=GET
2nd is PHP file - which based on inputs will display appropriate multiplication table of chosen number
[This one is little modified from 2-page App Ex # 7 in Week 9 content]
Multiplication Tables:
Go back to the multiplication table exercise from the previous class
a. Make it get the number as well as rows from user - on HTNL form. (Assume a default value of 10 if 'number of rows' is missing but put a warning on the page in red text in that case)
b. The title for the table [Add HTML5 form checking to enforce the following limits: the custom title of the page
must be 40 characters or less]
c. Foreground, background, and heading background colors. (using input type=color on the form)
d. Add PHP data validation to make sure the parameters (including the colors) are present and
contain valid values before you use them
[I have already limited/modified requirements - so, now you have to meet ALL a) to d) requirements mentioned above]
Upload both - HTML & PHP file in zip file AS WELL AS link to access it from your server (and user/password; if any)
Please send me this assignment using notepad ++ for web dvelopment as soon possible
Explanation / Answer
Following is the answer:
form.html
<html>
<body>
<form method="GET" action="index.php">
Number:
<input type="number" name="number" required />
Number of Rows:
<input type="number" name="rows" required />
Title:
<input type="text" name="title" maxlength="40" required />
Foreground:
<input type="color" name="fg" required/>
Background:
<input type="color" name="bg" required/>
BackgroundTitle:
<input type="color" name="bgtitle" required/>
<input type="submit" name="submit" value="submit"/>
</form>
</body>
</html>?
index.php
<?php
$numberErr = $rowErr = $titleErr = $fgErr = $bgErr = $bgtitleErr = "";
$number = $row = $title = $fg = $bg = $bgtitle = "";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
if (empty($_GET["number"])) {
$numberErr = "Number is Missing";
}
else {
$number = $_GET["number"];
}
if (empty($_GET["rows"])) {
$rowErr = "Number of Row is Missing";
$row = 10;
}
else {
$row = $_GET["rows"];
}
if (empty($_GET["title"])) {
$titleErr = "Title is Missing";
}
else {
$title = $_GET["title"];
}
if (!isset($_GET["fg"])) {
$fgErr = "foreground color is missing";
}
else {
$fg = $_GET["fg"];
}
if (empty($_GET["bg"])) {
$bgErr = "background color is missing";
}
else {
$bg = $_GET["bg"];
}
if (empty($_GET["bgtitle"])) {
$bgtitleErr = "background title color is missing";
}
else {
$bgtitle = $_GET["bgtitle"];
}
}
echo $numberErr . " " . $titleErr . " " . $fgErr . " " . $bgErr . " " . $bgtitleErr . " " ;
?>
<html>
<body>
<p><?php echo $rowErr; ?></p>
<table>
<tr style=<?php echo "background-color:".$bgtitle; ?>>
<td>Count</td>
</tr>
<?php for($i = 0 ; $i< $row ; $i++){ ?>
<tr style=<?php echo "background:".$bg; ?>>
<td style=<?php echo "color:".$fg; ?>><?php echo $number. " * " . ($i+1) . " = " . $number*($i+1); ?></td>
</tr>
<?php } ?>
</table>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.