在PHP表单中选中取消选中

时间:2019-05-01 18:11:03

标签: php forms checkbox

我尝试过:

self.uart = serial.Serial()
self.uart.port = '/dev/tty/USB0'
self.uart.baudrate = 115200
self.uart.open()
# buffer for received bytes
packet_bytes = bytearray()
# read and process data from serial port
while True:
    # read single byte from serial port
    current_bytes = self._uart.read()
    if current_bytes is B'$':
        self.process_packet(packet_bytes)
        packet_bytes = bytearray()
    else:
        packet_bytes.append(current_bytes)        <- Error occurs here

如果选中表格,则该表格可以正常运行。但是,如果表单未选中 ,则会有一个通知:

  

通知:未定义的索引:Privilege_Question_Name

1 个答案:

答案 0 :(得分:0)

首先不会发送未选中的复选框,因此请检查是否已设置它。

if (isset($_POST['submit'])) {
    $Privilege_Question_Query = isset($_POST['Privilege_Question_Name']) ? 'Y' : 'N';
    echo $Privilege_Question_Query;
    exit();
}