Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

<!-- To change this template, choose Tools | Templates and open the template in

ID: 3824106 • Letter: #

Question

<!--

To change this template, choose Tools | Templates

and open the template in the editor.

-->

<!DOCTYPE html>

<html>

<head>

<META CHARSET="UTF-8">

<title></title>

<script>

function allnumeric(inputtxt)

{

var numbers = /^[0-9]+$/;

// For count_network

if(inputtxt.count_network.value.match(numbers) & inputtxt.count_memory.value.match(numbers) && inputtxt.count_hdd.value.match(numbers))

{

alert('Your Registration number has accepted....');

inputtxt.count_network.focus();

return true;

}

else

{

alert('Please input numeric characters only');

inputtxt.count_memory.focus();

return false;

}

}

</script>

</head>

<body>

<form name = "myform" action="/formtest.php">

Customer name:&nbsp;&nbsp;

<input type="text" name="Customer">

<br><br>Address:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input type="text" name="address">

<br><br>

<p>Payment Choices</p>

<input type="radio" name="payment" value="Visa" checked>

<label for="Visa">&nbsp;&nbsp;&nbsp;&nbsp;Visa</label><br>

<input type="radio" name="payment" value="MasterCard">

<label for="MasterCard">&nbsp;&nbsp;&nbsp;&nbsp;MasterCard</label><br>

<input type="radio" name="payment" value="AmericanExpress">

<label for="AmericanExpress">&nbsp;&nbsp;&nbsp;&nbsp;AmericanExpress</label>

<br><br>

<b> Enter quantity :-</b>

<br><br>

List-Memory Upgrade :- <input type="text" name="count_memory" id = "count_memory">

<br><br>

  

List-HDD Upgrade :- <input type="text" name="count_hdd" id = "count_hdd">

<br><br>

List- Network Upgrade :- <input type="text" name="count_network" id = "count_network">

<br><br>

  

<input type="submit" name="submit" value="Submit">

</form>

</body>

</html>

<!DOCTYPE html>

<!--

-->

<html>

<head>

<title>Lab 7</title>

<meta charset="UTF-8">

<link rel="weblab.kennesaw.edu/tools" type="image/x-icon" />

<link rel="stylesheet" type="text/css" href="l2p4.css" />

</head>

<body>

<h1>Tool for Sale!</h1>

<h2>Price is based on unit weight</h2>

<form action="http://weblab.kennesaw.edu/formtest.php" method="post" id="form">

<table>

<tr>

<th>Tool</th>

<th>Price ($/lb)</th>

<th>Weight</th>

<th>Quantity</th>

</tr>

<?php

$db = pg_connect("dbname=webdev");

$query = "select tool_item_no, tool_name, tool_price, tool_weight";

$query .= " from tool_t order";

$query .= " by tool_name;";

$dbResult = pg_query($query);

if(!$dbResult){

die("Database error....");

}

  

$num = pg_num_rows($dbResult);

if($num == 0) {

echo '<tr><td colspan="2">';

echo 'Database query retrieved nothing!</td></tr>';

}

$i = 0;

while($i < $num) {

$tool_item_no = pg_Result($dbResult, $i, 'tool_item_no');

$name = pg_Result($dbResult, $i, 'tool_name');

$price = pg_Result($dbResult, $i, 'tool_price');

$weight = pg_Result($dbResult, $i, 'tool_weight');

echo '<tr><td>'.$name.'</td><td>'.$price.'</td><td>'.$weight.'.</td><td>';

echo '<input type="text" name="'.$tool_item_no.'" id="'.$tool_item_no.'" size="10" /></td></tr>';

$i++;

}

?>

</table>

<divi class="custInfo">

<label>First Name

<input type="text" id="fname" name="firstName" size="30" />

</label>

<label>Last Name

<input type="text" id="lname" name="lastName" size="30" />

</label>

  

<br />

  

<label>Street Address

<input type="text" id="streetAdr" name="streetAddress" size="45" />

</label>

<br />

<label>City

<input type="text" id="city" name="City" size="30" />

</label>

  

<label>State</label>

  

<select id="state" name="State">

<?php

$db=pg_connect("dbname=weblab");

$query = "select state_abbr, state_name from state_t order by state_name";

$dbResult = pg_query($query);

if(!$dbResult){

die("Database error....");

}

  

$num = pg_num_rows($dbResult);

if($num == 0) {

echo '<p>';

echo 'Database query retrieved nothing!</p>';

}

$i = 0;

while($i < $num) {

$state = pg_Result($dbResult, $i, 'state_name');

$abbr = pg_Result($dbResult, $i, 'state_abbr');

if($state == "Georgia") {

echo '<option value="'.$abbr.'" selected="selected">'.$state.'</option>';

echo " ";

} else {

echo '<option value="'.$abbr.'">'.$state.'</option>';

echo " ";

}

$i++;

}

?>

</select>

<label>Zip Code

<input type="text" id="zip" name="zipCode" size="10" />

</label>

  

<br />

  

<label>Payment:

<br />

<input type="radio" name="radio" name="payment" value="visa" />Visa

<input type="radio" name="radio" name="payment" value="master" />Mastercard

<input type="radio" name="radio" name="payment" value="discover" />Discover

<input type="radio" name="radio" name="payment" value="amex" />American Express

</label>

<br />

<br />

<input type="submit" value="Submit" />

</div>

</form>

<br /><br />

<p>Part 3:</p>

<p>I used it for my name and id field for the text box. This way when I go to look up the tool again later on I already have the primary key and thus have to supply less information.

I can send back the primary key and the quantity and everything else I can look up. Now if prices change frequently this may not be a good way to do it initially since then I could possibly give them

the wrong price but only fairly staticly priced items it should be fine.

</p>

<p>Part 4:</p>

<p>To get the validation to work I would have to connect to the database and figure out what possible fields I have, based on how many unique ID's I have. From there it wouldn't require much to change, put the various ID's into an

array. Then loop over them and check to make sure it's a number.

</p>

<p>Part 5:</p>

<p>The small time I was in your course I had no problems with it. I was also hoping to learn more frameworks and the backend of stuff more. I know this wasn't meant to be an advanced web programming course and thus basics have to be covered.

I know you would like a list but overall this was my only complaint which isn't much of one to begin with. Hope you have a great summer!

</p>

</body>

</html>

found errors here-

Warning: The preferred Content-Type for XHTML5 is application/xhtml+xml. The Content-Type was application/octet-stream.

Error: Unnamespaced element html not allowed in this context. (Suppressing further errors from this subtree.)

From line 5, column 16; to line 6, column 6

TYPE html><html><head

Fatal Error: name expected

At line 15, column 48

match(numbers) & inputtxt.coun

Fix these errors and update it

Explanation / Answer

We cannot have two <html> tags in one html file. Hence, we can either separate the code into two html pages or rewrite the code to have a single html start and end tag. I have added the code for both the approaches below.

1. Having two separate pages

a. Page One

<!DOCTYPE html>
<html>
<head>
<META CHARSET="UTF-8">
<title></title>
<script>
function allnumeric(inputtxt)
{
var numbers = /^[0-9]+$/;
// For count_network
if(inputtxt.count_network.value.match(numbers) & inputtxt.count_memory.value.match(numbers) && inputtxt.count_hdd.value.match(numbers))
{
alert('Your Registration number has accepted....');
inputtxt.count_network.focus();
return true;
}
else
{
alert('Please input numeric characters only');
inputtxt.count_memory.focus();
return false;
}
}
</script>
</head>
<body>
<form name = "myform" action="/formtest.php">
Customer name:&nbsp;&nbsp;
<input type="text" name="Customer">
<br><br>Address:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="address">
<br><br>
<p>Payment Choices</p>
<input type="radio" name="payment" value="Visa" checked>
<label for="Visa">&nbsp;&nbsp;&nbsp;&nbsp;Visa</label><br>
<input type="radio" name="payment" value="MasterCard">
<label for="MasterCard">&nbsp;&nbsp;&nbsp;&nbsp;MasterCard</label><br>
<input type="radio" name="payment" value="AmericanExpress">
<label for="AmericanExpress">&nbsp;&nbsp;&nbsp;&nbsp;AmericanExpress</label>
<br><br>
<b> Enter quantity :-</b>
<br><br>
List-Memory Upgrade :- <input type="text" name="count_memory" id = "count_memory">
<br><br>
  
List-HDD Upgrade :- <input type="text" name="count_hdd" id = "count_hdd">
<br><br>
List- Network Upgrade :- <input type="text" name="count_network" id = "count_network">
<br><br>
  
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

b. Page Two

<!DOCTYPE html>
<!--
-->
<html>
<head>
<title>Lab 7</title>
<meta charset="UTF-8">
<link rel="weblab.kennesaw.edu/tools" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="l2p4.css" />
</head>
<body>
<h1>Tool for Sale!</h1>
<h2>Price is based on unit weight</h2>
<form action="http://weblab.kennesaw.edu/formtest.php" method="post" id="form">
<table>
<tr>
<th>Tool</th>
<th>Price ($/lb)</th>
<th>Weight</th>
<th>Quantity</th>
</tr>
<?php
$db = pg_connect("dbname=webdev");
$query = "select tool_item_no, tool_name, tool_price, tool_weight";
$query .= " from tool_t order";
$query .= " by tool_name;";
$dbResult = pg_query($query);

if(!$dbResult){
die("Database error....");
}
  
$num = pg_num_rows($dbResult);

if($num == 0) {
echo '<tr><td colspan="2">';
echo 'Database query retrieved nothing!</td></tr>';
}

$i = 0;
while($i < $num) {
$tool_item_no = pg_Result($dbResult, $i, 'tool_item_no');
$name = pg_Result($dbResult, $i, 'tool_name');
$price = pg_Result($dbResult, $i, 'tool_price');
$weight = pg_Result($dbResult, $i, 'tool_weight');

echo '<tr><td>'.$name.'</td><td>'.$price.'</td><td>'.$weight.'.</td><td>';
echo '<input type="text" name="'.$tool_item_no.'" id="'.$tool_item_no.'" size="10" /></td></tr>';
$i++;
}
?>
</table>

<divi class="custInfo">
<label>First Name
<input type="text" id="fname" name="firstName" size="30" />
</label>
<label>Last Name
<input type="text" id="lname" name="lastName" size="30" />
</label>
  
<br />
  
<label>Street Address
<input type="text" id="streetAdr" name="streetAddress" size="45" />
</label>

<br />

<label>City
<input type="text" id="city" name="City" size="30" />
</label>

  
<label>State</label>
  
<select id="state" name="State">
<?php
$db=pg_connect("dbname=weblab");
$query = "select state_abbr, state_name from state_t order by state_name";

$dbResult = pg_query($query);

if(!$dbResult){
die("Database error....");
}
  
$num = pg_num_rows($dbResult);

if($num == 0) {
echo '<p>';
echo 'Database query retrieved nothing!</p>';
}

$i = 0;
while($i < $num) {
$state = pg_Result($dbResult, $i, 'state_name');
$abbr = pg_Result($dbResult, $i, 'state_abbr');

if($state == "Georgia") {
echo '<option value="'.$abbr.'" selected="selected">'.$state.'</option>';
echo " ";
} else {
echo '<option value="'.$abbr.'">'.$state.'</option>';
echo " ";
}
$i++;
}
?>
</select>
<label>Zip Code
<input type="text" id="zip" name="zipCode" size="10" />
</label>

  
<br />
  
<label>Payment:
<br />
<input type="radio" name="radio" name="payment" value="visa" />Visa
<input type="radio" name="radio" name="payment" value="master" />Mastercard
<input type="radio" name="radio" name="payment" value="discover" />Discover
<input type="radio" name="radio" name="payment" value="amex" />American Express
</label>

<br />
<br />
<input type="submit" value="Submit" />
</div>
</form>

<br /><br />
<p>Part 3:</p>
<p>I used it for my name and id field for the text box. This way when I go to look up the tool again later on I already have the primary key and thus have to supply less information.
I can send back the primary key and the quantity and everything else I can look up. Now if prices change frequently this may not be a good way to do it initially since then I could possibly give them
the wrong price but only fairly staticly priced items it should be fine.
</p>

<p>Part 4:</p>
<p>To get the validation to work I would have to connect to the database and figure out what possible fields I have, based on how many unique ID's I have. From there it wouldn't require much to change, put the various ID's into an
array. Then loop over them and check to make sure it's a number.
</p>

<p>Part 5:</p>
<p>The small time I was in your course I had no problems with it. I was also hoping to learn more frameworks and the backend of stuff more. I know this wasn't meant to be an advanced web programming course and thus basics have to be covered.
I know you would like a list but overall this was my only complaint which isn't much of one to begin with. Hope you have a great summer!
</p>
</body>
</html>

2. Combining the page into a single page

Here I am removing the header of the second page and giving each form an id to identify it with. Following is th code.

<!DOCTYPE html>
<html>
<head>
<META CHARSET="UTF-8">
<title></title>
<script>
function allnumeric(inputtxt)
{
var numbers = /^[0-9]+$/;
// For count_network
if(inputtxt.count_network.value.match(numbers) & inputtxt.count_memory.value.match(numbers) && inputtxt.count_hdd.value.match(numbers))
{
alert('Your Registration number has accepted....');
inputtxt.count_network.focus();
return true;
}
else
{
alert('Please input numeric characters only');
inputtxt.count_memory.focus();
return false;
}
}
</script>
</head>
<body>
<form id="form1" name = "myform" action="/formtest.php">
Customer name:&nbsp;&nbsp;
<input type="text" name="Customer">
<br><br>Address:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="address">
<br><br>
<p>Payment Choices</p>
<input type="radio" name="payment" value="Visa" checked>
<label for="Visa">&nbsp;&nbsp;&nbsp;&nbsp;Visa</label><br>
<input type="radio" name="payment" value="MasterCard">
<label for="MasterCard">&nbsp;&nbsp;&nbsp;&nbsp;MasterCard</label><br>
<input type="radio" name="payment" value="AmericanExpress">
<label for="AmericanExpress">&nbsp;&nbsp;&nbsp;&nbsp;AmericanExpress</label>
<br><br>
<b> Enter quantity :-</b>
<br><br>
List-Memory Upgrade :- <input type="text" name="count_memory" id = "count_memory">
<br><br>
  
List-HDD Upgrade :- <input type="text" name="count_hdd" id = "count_hdd">
<br><br>
List- Network Upgrade :- <input type="text" name="count_network" id = "count_network">
<br><br>
  
<input type="submit" name="submit" value="Submit">
</form>


<h1>Tool for Sale!</h1>
<h2>Price is based on unit weight</h2>
<form action="http://weblab.kennesaw.edu/formtest.php" method="post" id="form2">
<table>
<tr>
<th>Tool</th>
<th>Price ($/lb)</th>
<th>Weight</th>
<th>Quantity</th>
</tr>
<?php
$db = pg_connect("dbname=webdev");
$query = "select tool_item_no, tool_name, tool_price, tool_weight";
$query .= " from tool_t order";
$query .= " by tool_name;";
$dbResult = pg_query($query);

if(!$dbResult){
die("Database error....");
}
  
$num = pg_num_rows($dbResult);

if($num == 0) {
echo '<tr><td colspan="2">';
echo 'Database query retrieved nothing!</td></tr>';
}

$i = 0;
while($i < $num) {
$tool_item_no = pg_Result($dbResult, $i, 'tool_item_no');
$name = pg_Result($dbResult, $i, 'tool_name');
$price = pg_Result($dbResult, $i, 'tool_price');
$weight = pg_Result($dbResult, $i, 'tool_weight');

echo '<tr><td>'.$name.'</td><td>'.$price.'</td><td>'.$weight.'.</td><td>';
echo '<input type="text" name="'.$tool_item_no.'" id="'.$tool_item_no.'" size="10" /></td></tr>';
$i++;
}
?>
</table>

<divi class="custInfo">
<label>First Name
<input type="text" id="fname" name="firstName" size="30" />
</label>
<label>Last Name
<input type="text" id="lname" name="lastName" size="30" />
</label>
  
<br />
  
<label>Street Address
<input type="text" id="streetAdr" name="streetAddress" size="45" />
</label>

<br />

<label>City
<input type="text" id="city" name="City" size="30" />
</label>

  
<label>State</label>
  
<select id="state" name="State">
<?php
$db=pg_connect("dbname=weblab");
$query = "select state_abbr, state_name from state_t order by state_name";

$dbResult = pg_query($query);

if(!$dbResult){
die("Database error....");
}
  
$num = pg_num_rows($dbResult);

if($num == 0) {
echo '<p>';
echo 'Database query retrieved nothing!</p>';
}

$i = 0;
while($i < $num) {
$state = pg_Result($dbResult, $i, 'state_name');
$abbr = pg_Result($dbResult, $i, 'state_abbr');

if($state == "Georgia") {
echo '<option value="'.$abbr.'" selected="selected">'.$state.'</option>';
echo " ";
} else {
echo '<option value="'.$abbr.'">'.$state.'</option>';
echo " ";
}
$i++;
}
?>
</select>
<label>Zip Code
<input type="text" id="zip" name="zipCode" size="10" />
</label>

  
<br />
  
<label>Payment:
<br />
<input type="radio" name="radio" name="payment" value="visa" />Visa
<input type="radio" name="radio" name="payment" value="master" />Mastercard
<input type="radio" name="radio" name="payment" value="discover" />Discover
<input type="radio" name="radio" name="payment" value="amex" />American Express
</label>

<br />
<br />
<input type="submit" value="Submit" />
</div>
</form>

<br /><br />
<p>Part 3:</p>
<p>I used it for my name and id field for the text box. This way when I go to look up the tool again later on I already have the primary key and thus have to supply less information.
I can send back the primary key and the quantity and everything else I can look up. Now if prices change frequently this may not be a good way to do it initially since then I could possibly give them
the wrong price but only fairly staticly priced items it should be fine.
</p>

<p>Part 4:</p>
<p>To get the validation to work I would have to connect to the database and figure out what possible fields I have, based on how many unique ID's I have. From there it wouldn't require much to change, put the various ID's into an
array. Then loop over them and check to make sure it's a number.
</p>

<p>Part 5:</p>
<p>The small time I was in your course I had no problems with it. I was also hoping to learn more frameworks and the backend of stuff more. I know this wasn't meant to be an advanced web programming course and thus basics have to be covered.
I know you would like a list but overall this was my only complaint which isn't much of one to begin with. Hope you have a great summer!
</p>
</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote