کاری نداره که خودت بسازش
http://jilasadeghi.ir/%D8%AB%D8%A8%D...7-%D9%87%D8%A7
برگه ثبت نام :
<?php
/*
Template Name: ثبت نام در دوره ها
*/
ob_start("sanitize_output");
error_reporting(true);
define("DIR", dirname(__FILE__) . '/');
// header
if(file_exists(DIR . 'header.php'))
include_once(DIR . 'header.php');
// body
if(file_exists(DIR . 'register-body.php'))
include_once(DIR . 'register-body.php');
// footer
if(file_exists(DIR . 'footer.php'))
include_once(DIR . 'footer.php');
اسکریپت ولیدیشن های فرم (فرم رو اینجا نذاشتم نیازی نیست)
var FIELDS = [];
FIELDS.push({ID: "name", REQ: true, MIN: 3});
FIELDS.push({ID: "cityName", REQ: false, MIN: 2});
FIELDS.push({ID: "emailAccount", REQ: true, MIN: 8, TYPE: /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/});
FIELDS.push({ID: "telNumber", REQ: false, MIN: 6, TYPE: /^\d+$/});
FIELDS.push({ID: "mobileNumber", REQ: true, MIN: 11, TYPE: /^\d+$/});
FIELDS.push({ID: "history", REQ: false, MIN: 1});
FIELDS.push({ID: "historyDescribe", REQ: false, MIN: 3});
FIELDS.push({ID: "priority", REQ: true, MIN: 3});
FIELDS.push({ID: "tuition", MIN: 3, TYPE: /^\d+$/});
FIELDS.push({ID: "note", REQ: false, MIN: 3});
FIELDS.push({ID: "Captcha", REQ: true, MIN: 5, TYPE: /^\d+$/});
$(function() {
var texts = $("div.registration :text");
var btnSubmit = $("#save_input_values");
var btnClear = $("#clear_inputs");
var field = {}, tF, theField, tfLen;
var inProcess = false;
var cimage = $("#captcha_image");
var resultArea = $(".result_value");
var eUrl = 'http://jilasadeghi.ir/reg/';
var style;
function changeCaptcha() {
var captcha = eUrl + 'c/?' + Math.random();
cimage.attr("src", captcha);
}
cimage.on('click', function(){changeCaptcha();});
btnClear.on('click', function() {
$("div.registration :text, div.registration textarea").val("");
changeCaptcha();
});
btnSubmit.on('click', function() {
if (inProcess)
return;
if (typeof FIELDS !== 'object') {
alert('برخی از اطلاعات موجود نمی باشد، نمی توان لاینک به ذخیره سازی اطلاعات پرداخت');
return;
}
for (var index = 0; index < FIELDS.length; index++) {
tF = (FIELDS[index]);
style = "";
if ($("#" + tF.ID).length < 1) {
alert('برخی از اطلاعات موجود نمی باشد، نمی توان لاینک به ذخیره سازی اطلاعات پرداخت');
return;
}
theField = $("#" + tF.ID);
if (tF.REQ) {
tfLen = theField.val().length;
if ((parseInt(tfLen) - parseInt(tF.MIN)) < 0) {
theField.addClass('required');
if (theField.next("span").length < 1){
if(tF.ID === 'Captcha')
style = ' style="margin-right: 284px;"';
theField.focus().after('<span'+ style +'>حداقل ' + tF.MIN + " کاراکتر</span>");
}
$("html, body").animate({scrollTop: theField.offset().top - 20}, 400);
return;
}
}
if (tF.REQ && typeof tF.TYPE !== "undefined") {
var t = tF.TYPE;
if (!t.test(theField.val())) {
if (theField.next("span").length > 0)
theField.removeClass('required').next("span").remo ve();
theField.addClass('required');
if(tF.ID === 'Captcha')
style = ' style="margin-right: 284px;"';
theField.select().after('<span'+ style +'>بشکل صحیح وارد کنید</span>');
$("html, body").animate({scrollTop: theField.offset().top - 20}, 400);
return;
}
}
if (theField.hasClass('required')) {
theField.removeClass('required').next("span").remo ve();
}
if (theField.val() !== "" && theField.val() !== "undefined")
field[tF.ID] = theField.val();
}
if (field.name !== "undefined") {
inProcess = true;
resultArea.html("").addClass("mini_loading");
$.post(eUrl, {data: field}, function(Response) {
var isObj = true;
var oBj;
if (Response && Response !== "") {
try
{
oBj = $.parseJSON(Response);
}
catch (err)
{
isObj = false;
}
}
if(oBj.Error !== "undefined" && oBj.Error){
resultArea.removeClass("mini_loading").css("backgr ound","#eee").html(oBj.Error_value);
inProcess = false;
return;
}
if(oBj.Success !== "undefined" && !oBj.Error){
resultArea.removeClass("mini_loading").css("backgr ound","#eee").html(oBj.Success);
btnClear.click();
inProcess = false;
return;
}
});
}
});
changeCaptcha();
});
اسکریپت php جهت ثبت در دیتابیس
if (!isset($_SESSION['captcha']) || !isset($data['Captcha']) || $_SESSION['captcha'] != $data['Captcha']) {
die(json_encode(["Error" => true, "Error_value" => "کد امنیتی بصورت صحیح وارد نشده است"]));
}
// check is error occurred
if ($error) {
die(json_encode(["Error" => true, "Error_value" => "بخشی از اطلاعات ناقص و یا وارد نشده است، نمی توان ادامه داد"]));
}
// include wordpress
require_once ('../../wp-load.php');
// check is wpdb included
if (!class_exists("wpdb")) {
die(json_encode(["Error" => true, "Error_value" => "کلاس مورد استفاده ایجاد نشده و یا قابل دسترس نمی باشد"]));
}
// create data to use in databass insert
$tData = array();
foreach ($data as $key => $value) {
if ($key === "Captcha")
continue;
$tData[$key] = $value;
}
$table_name = $wpdb->prefix . "students";
$Success = $wpdb->insert($table_name, $tData);
if ($Success) {
unset($_SESSION['captcha']);
$_SESSION['regTime'] = time() + (5 * 60);
die(json_encode(["Error" => false, "Success" => "تبریک، اطلاعات با موفقیت ثبت شد" . " - (" . $data['name'] . ")"]));
}
die(json_encode(["Error" => true, "Error_value" => "اتفاقی ناخواسته به وجود آمده است، یا بخشی از اطلاعات در دسترس نمی باشد"]));
همین کار خاص دیگه ای نداره
یکی هم میمونه قسمت مشاهده اطلاعات ثبت شده که یه پلاگین خیلی ساده براش بنویسی و از خود وردپرس کمک بگیری تمومه
اینم برای نمایش تیبل هستش :
<?php
if (!class_exists('WP_List_Table')) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
class ListStudents extends WP_List_Table {
var $TableData = array();
function __construct() {
global $status, $page;
parent::__construct(array(
'singular' => __('Students', 'mylisttable'),
'plural' => __('Students', 'mylisttable'),
'ajax' => true
));
$this->getData();
}
function getData() {
$Data = array();
$theRetData = array();
global $wpdb;
$table_name = $wpdb->prefix . "****";
$customers = $wpdb->get_results("SELECT * FROM $table_name ORDER BY *** DESC;");
$i = 0;
require_once dirname(__FILE__) . '/Encryption.php';
foreach ($customers as $row) {
$i++;
foreach ($row as $key => $value) {
$theRetData['row'] = $i;
if ($key === "id") {
$s = new Encryption();
$value = $s->CreateToken($value);
}
$theRetData[$key] = $value;
}
$Data[] = $theRetData;
unset($theRetData);
}
$this->TableData = $Data;
}
function admin_header() {
echo '<style type="text/css">';
echo '.wp-list-table th {font-size:12px!important;color: #818181;}';
echo '.wp-list-table td {font-size:11px!important;}';
echo '.wp-list-table .column-row { width: 43px;text-align:center}';
echo '.wp-list-table .column-name { width: 110px; }';
echo '.wp-list-table .name { color: #D81D1D; }';
echo '.wp-list-table .column-cityName { width: 100px;text-align:center }';
echo '.wp-list-table .column-emailAccount { width: auto;text-align:center }';
echo '.wp-list-table .column-telNumber { width: auto;text-align:center}';
echo '.wp-list-table .column-mobileNumber { width: auto;text-align:center}';
echo '.wp-list-table .column-history { width: auto;text-align:center}';
echo '.wp-list-table .column-historyDescribe { width: auto;}';
echo '.wp-list-table .column-priority { width: auto;text-align:center}';
echo '.wp-list-table .column-tuition { width: auto;text-align:center}';
echo '.wp-list-table .column-note { width: auto;}';
echo '</style>';
}
function no_items() {
_e('موردی یافت نشد');
}
function column_default($item, $column_name) {
switch ($column_name) {
case '**':
case '**':
case '**':
case '**':
case '**':
case '**':
case '***':
case '*****':
case '**':
case '**':
case '**':
case '***':
return $item[$column_name];
default:
return print_r($item, true);
}
}
function get_sortable_columns() {
/*
$sortable_columns = array(
'cityName' => array('cityName', false),
'row' => array('row', false)
);
return $sortable_columns;
*/
}
function get_columns() {
$columns = array(
'**' => __('#', 'mylisttable'),
'***' => __('نام و نام خانوادگی', 'mylisttable'),
'***' => __('محل سکونت', 'mylisttable'),
'***' => __('ایمیل', 'mylisttable'),
'***' => __('تلفن', 'mylisttable'),
'**' => __('موبایل', 'mylisttable'),
'**' => __('سابقه هنری', 'mylisttable'),
'**' => __('توضیح سابقه', 'mylisttable'),
'**' => __('دوره', 'mylisttable'),
'***' => __('پ. شهریه', 'mylisttable'),
'***' => __('یادداشت', 'mylisttable')
);
return $columns;
}
function usort_reorder($a, $b) {
// If no sort, default to title
$orderby = (!empty($_GET['orderby']) ) ? $_GET['orderby'] : '**';
// If no order, default to asc
$order = (!empty($_GET['order']) ) ? $_GET['order'] : 'asc';
// Determine sort order
$result = strcmp($a[$orderby], $b[$orderby]);
// Send final sort direction to usort
return ( $order === 'asc' ) ? $result : -$result;
}
function column_name($item) {
$file = basename(__FILE__);
$dlete = str_replace($file, 'delete.php', $_REQUEST['page']);
$edit = str_replace($file, 'edit.php', $_REQUEST['page']);
$actions = array(
'edit' => sprintf('<a href="?page=%s&token=%s">ویرایش</a>', $edit, $item['**']),
'delete' => sprintf('<a href="?page=%s&token=%s">حذف</a>', $dlete, $item['**']),
);
return sprintf('%1$s %2$s', $item['name'], $this->row_actions($actions));
}
/*
function get_bulk_actions() {
//$actions = array(
// '-' => 'غیر قابل انجام فعالیتهای دسته جمعی'
//);
//return $actions;
}
*/
function prepare_items() {
$this->admin_header();
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
// usort($this->TableData, array(&$this, 'usort_reorder'));
$per_page = 10;
$current_page = $this->get_pagenum();
$total_items = count($this->TableData);
// only ncessary because we have sample data
$this->found_data = array_slice($this->TableData, ( ( $current_page - 1 ) * $per_page), $per_page);
$this->set_pagination_args(array(
'total_items' => $total_items, //WE have to calculate the total number of items
'per_page' => $per_page //WE have to determine how many items to show on a page
));
$this->items = $this->found_data;
}
}
//class
$option = 'per_page';
$args = array(
'label' => 'Students',
'default' => 10,
'option' => 'Student_per_page'
);
add_screen_option($option, $args);
$myListTable = new ListStudents();
echo '</pre><div class="wrap">
';
$myListTable->prepare_items();
?>
<form method="post">
<input type="hidden" name="page" value="ttest_list_table">
<?php
//$myListTable->search_box('جستجو', '**');
$myListTable->display();
?>
</form></div>
موفق باشید