CREATE TABLE `tbl_member` ( `tbl_member_id` INT(11) NOT NULL, `first_name` VARCHAR(100) NOT NULL, `last_name` VARCHAR(100) NOT NULL, `contact_number` VARCHAR(100) NOT NULL, `email` VARCHAR(100) NOT NULL, `address` VARCHAR(100) NOT NULL, `expiration_date` VARCHAR(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
<?php $conn = new PDO('mysql:host=localhost; dbname=delete_by_date','root', ''); ?>
<form method="post" action="add_person_query.php"> <table border="1" cellspacing="5" cellpadding="5" width="100%"> <tr> <td> </td> <td width="395px"> <input type="text" class="text_Box" name="first_name" autofocus="autofocus" placeholder="First Name ....." required /> </td> </tr> <tr> <td> </td> <td width="395px"> <input type="text" class="text_Box" name="last_name" placeholder="Last Name ....." required /> </td> </tr> <tr> <td> </td> <td width="395px"> <input type="text" class="text_Box" name="contact_number" placeholder="Contact Number ....." required /> </td> </tr> <tr> <td> </td> <td width="395px"> <input type="email" class="text_Box" name="email" placeholder="Email ....."> </td> </tr> <tr> <td> </td> <td width="395px"> <input type="text" class="text_Box" name="address" placeholder="Address ....." required /> </td> </tr> <tr> <td> </td> <td width="395px"> <input type="text" class="text_Box" name="number_of_days" placeholder="Number of Days ....." required /> </td> </tr> <tr> <td colspan="2"> <a> <button type="submit" class="btn_confirm"> Save Data </button> </a> </td> </tr> </table> </form>
<?php include ('db.php'); $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $contact_number = $_POST['contact_number']; $email = $_POST['email']; $address = $_POST['address']; $number_of_days = $_POST['number_of_days']; $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "INSERT INTO tbl_member (first_name, last_name, contact_number, email, address, expiration_date) VALUES ('$first_name', '$last_name', '$contact_number', '$email', '$address', '$expiration_date')"; echo "<script>alert('Successfully Added!'); window.location='index.php'</script>"; ?>
<?php require_once('db.php'); // sql to delete a record $sql = "Delete from tbl_member where expiration_date = '$curdate'"; // use exec() because no results are returned ?>