We’re going to dive into the world of WordPress and learn how to create a custom CRUD (Create, Read, Update, Delete) system in the WordPress admin area without relying on plugins. This tutorial will walk you through creating your own tables and managing data within them.
submit.php // Template Name: Submit Event Data global $wpdb; $etitle = $_POST['etitle']; $edate = $_POST['edate']; $ecost = $_POST['ecost']; $table_name = 'wp_events'; $wpdb->insert( $table_name, array( 'title' => $etitle, 'date' => $edate, 'cost' => $ecost, ) ); echo "<script>location.replace('admin.php?page=crud.php');</script>";
event.php
<form action="/event-submit">
<h3><b>Add Events Form</b></h3>
<hr/>
<div class="form-group">
<label for="name">Event Title:</label>
<input type="name" class="form-control" id="name" name="etitle">
</div>
<div class="form-group">
<label for="edate">Event date:</label>
<input type="date" class="form-control" id="edate" name="edate">
</div>
<div class="form-group">
<label for="number">Cost:</label>
<input type="number" class="form-control" id="ecost" name="ecost">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>