最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Sending data with multi step form to wp database

programmeradmin3浏览0评论

I have a multi step form and I need to save data from each step to the db. First step is contact details and by clicking button "Next" data should be saved to db.

In my form template I have js code for collecting and sanding data to php file

function Send_Data_Post_In() {
            var name = document.getElementById("first_name").value;
            var lastname = document.getElementById("last_name").value;
            var email = document.getElementById("user_email").value;
            var phone = document.getElementById("phone").value;

            var httpr = new XMLHttpRequest();
            httpr.open("POST", "/post-expance.php", true);
            httpr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

            httpr.send("&name=" + name + "&lastname=" + lastname + "$email" + email + "$phone" + phone);
            console.log(httpr);

        }

And php file is

include_once '/wp-config.php';

$name = $_POST['first_name'];
$lastname = $_POST['last_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];

$sql = "INSERT INTO step_form (first_name, last_name, email, phone) VALUES ('$name', '$lastname', '$email', '$phone');";

$result = mysqli_query($wpdb, $sql);
发布评论

评论列表(0)

  1. 暂无评论