-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert_db.php
More file actions
45 lines (37 loc) · 1.16 KB
/
insert_db.php
File metadata and controls
45 lines (37 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
//header("Content-Type: application/json; charset=utf-8");
require_once( explode( "wp-content" , __FILE__ )[0] . "wp-load.php" );
if(isset($_POST["submit"])) {
function test_input($data){
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$firstname=sanitize_text_field($_POST["firstname"]);
$lastname=sanitize_text_field($_POST["lastname"]);
$email=sanitize_text_field($_POST["email"]);
$message=sanitize_text_field($_POST["message"]);
$firstname=test_input($firstname);
$lastname=test_input($lastname);
$email=test_input($email);
$message=test_input($message);
global $wpdb;
$tablename = $wpdb->prefix.'table_test';
$data=array(
'firstname'=>$firstname,
'lastname'=>$lastname,
'email'=>$email,
'message'=>$message
);
$format=array('%s','%s','%s','%s');
$insert=$wpdb->insert($tablename,$data,$format);
if($insert){
echo "\nInsert Done";
header('Refresh: 3; URL=/wordpress/');
}else
{
$wpdb->show_errors();
}
}
?>