Reason:
$desc) { if (!isset($_POST[$name]) || empty($_POST[$name])) display_failure('The ' . $desc . ' field can not be empty'); $vars[$name] = $_POST[$name]; } return $vars; } function insert_details($dbh) { $vars = check_post_vars([ 'name' => 'Name', 'email' => 'E-mail address', 'date_of_birth' => 'Date of birth', 'city' => 'City', 'roll' => 'Roll No.' ]); $stmt = mysqli_prepare($dbh, 'INSERT INTO STUDENT ( ROLL, NAME, EMAIL, CITY, DATE_OF_BIRTH ) VALUES (?,?,?,?,?)'); mysqli_stmt_execute($stmt, [ $vars['roll'], $vars['name'], $vars['email'], $vars['city'], $vars['date_of_birth'] ]); } function show_table($dbh) { $result = mysqli_query($dbh, 'SELECT * FROM STUDENT'); html_prologue('Students\' details'); ?>record(s) found.
Roll No. | Name | City | Date of birth | |
---|---|---|---|---|
', array_map('htmlspecialchars', [ $row['ROLL'], $row['NAME'], $row['EMAIL'], $row['CITY'], $row['DATE_OF_BIRTH'] ])); ?> |