(1) Design an HTML form, hw6q1.php, for entering a product record (please refer
ID: 3602133 • Letter: #
Question
(1) Design an HTML form, hw6q1.php, for entering a product record (please refer to the Products table in the Northwind database). The form must contain input types that support the entries of productlD (integer), product name(string), supplierlD(integer), category ID (an integer between [1- 8]), unit price (decimal), units in stock (positive integer), discontinued (1 or 0). Radio input types must be used for the discontinued entry. Drop-down lists must be used for the supplierlD entry and categoryID entry to restrict the value range of supplierlD to 1-29 and that of categorylD to 1-8. (20 pts) (Due in class on Thursday, October 26, 2017) (2) Input validation: Write the PHP code that validates user entries. All form attributes are required except productlD. Do not use the "required" attribute in HTML. Use the PHP code to accomplish the task. Quantity per unit, unit price, units of stock must be greater than or equal to 0. If errors are found after the user submits the form, stay on the same PHP page and display an error message for each missing/incorrect user entry under the corresponding input element. Correct user entries should be kept on the PHP page while an error message is displayed for each incorrect entry within proximity. If no errors are found, direct the HTTP request to the PHP code developed for (3). (20 pts) (Due in class on Thursday, October 26, 2017)Explanation / Answer
/Atmega128 Example//
#include <avr/io.h>
#include <stdint.h>
// leds are connected to port A0..2
void initLeds() {
DDRA |= 0x7;
}
void ledOn(uint8_t sel) {
//if (sel > 7) return;
PORTA |= 1<<sel;
}
void ledOff(uint8_t sel) {
//if (sel > 7) return;
PORTA &= ~(1<<sel);
}
void ledToggle(uint8_t sel) {
//if (sel > 7) return;
PORTA ^= (1<<sel);
}
void ledSet(uint8_t val) {
PORTA = (PORTA & 0xF8) | (val & 0x7);
}
int main() {
initLeds();
ledOn(1);
ledOff(1);
ledToggle(1);
ledSet(5);
return 0;
}
//Pic24ep512gu810 Example//
#include <stdint.h>
#include "Compiler.h"
#include "ConfigurationBits.h"
// leds are connected to port D1..3
void initLeds() {
TRISD &= 0xFFF1;
}
void ledOn(uint8_t sel) {
LATD |= 1<<(sel+1);
}
void ledOff(uint8_t sel) {
LATD &= ~(1<<(sel+1));
}
void ledToggle(uint8_t sel) {
LATD ^= (1<<(sel+1));
}
void ledSet(uint8_t val) {
LATD = (LATD & 0xFFF1) | ((val & 0x7) <<1);
}
int main() {
initLeds();
ledOn(1);
ledOff(1);
ledToggle(1);
ledSet(5);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.