Add New Field:

Tag: id: class: name: Default value: order:
prefix . "design_form"; $tname = $_POST['tname']; $tid = $_POST['tid']; $class = $_POST['class']; $name = $_POST['name']; $value = $_POST['value']; $torder = $_POST['torder']; $wpdb->insert( $table_name, array( 'tname' => $tname, 'tid' => $tid, 'class' => $class, 'name' => $name, 'value' => $value, 'torder' => $torder ) ); } // single field update form function update_contact_dform() { global $wpdb; $table_name = $wpdb->prefix . "design_form"; $id = $_POST['eid']; $row = $wpdb->get_row("select * from $table_name where id=".$id.";"); ?>
Tag: id: class: name: Default value: order:
prefix . "design_form"; $did = $_POST['did']; $row = $wpdb->get_row("select * from $table_name where id=".$did.";"); echo "

Are you sure you want to delete form field with id ".$row->tid."?:

"; } // executes and confirm update to the DB function update_contact_form_confirm() { $itemId = $_POST['update']; $tname = $_POST['tname']; $tid = $_POST['tid']; $class = $_POST['class']; $name = $_POST['name']; $value = $_POST['value']; $torder = $_POST['torder']; global $wpdb; $table_name = $wpdb->prefix . "design_form"; $rows_affected = $wpdb->update( $table_name, array( 'tname' => $tname, 'tid' => $tid, 'class' => $class, 'name' => $name, 'value' => $value, 'torder' => $torder ), array('id' => $itemId) ); if($rows_affected) echo "

Form Field Successfully Updated!

"; else "Failed to update"; } // shows the total form function show_form() { global $wpdb; $table_name = $wpdb->prefix . "design_form"; $myrows = $wpdb->get_results("select * from $table_name order by torder ASC"); echo "

Here is Your Form:

"; //if($myrows) //echo ""; //else //echo ""; foreach($myrows as $myrow) { echo ""; echo ""; if($myrow->tid=='email' || $myrow->tid=='msgarea') { echo ""; } else { echo ""; echo ""; } echo ""; } echo "
IdFirst NameLast NameEmailDelete
There is no signed up member yet.
$myrow->value"; if($myrow->tname=='input') { echo "<"; echo $myrow->tname." id=\"$myrow->tid\" class=\"$myrow->class\" name=\"$myrow->name\" value=\"$myrow->value\""; echo " />"; } else { echo ""; } echo "*(required)
"; } // confirm the changes to the form if($_POST['add_field']) save_form_field(); if($_POST['update']) { update_contact_form_confirm(); } if($_POST['delete']) { $did = $_POST['cdid']; global $wpdb; $table_name = $wpdb->prefix . "design_form"; $delete_status = $wpdb->query("delete from $table_name where id=".$did.";"); if($delete_status) { echo "

Field Successfully Deleted!

"; } } // the form show_form(); // add, update, delete operations if($_POST['eid']) { ?>

Update Field with id:

"; } else if($_POST['did']) { ?>

[Note: please choose appropriate input for id, class and name.]