普通网友 2016-06-22 12:42
浏览 304

如何将表单数据保存到wordpress数据库中

I created a wordpress page that includes a form that emails to the admin some information with an attachment. I made this form without any plugins.

I'm wondering how would I have the form save data into the wordpress database which would be accessible to me?

Should I have used a plugin? I rather not to because I already worked hard without it. Yet i've seen ways where people saved to the database with the plugin.

In my code, I included the form html inside the get header/footers for a php page. and here is part of the code of how I mail the information itself:

$message .= '<table rules="all" style="border-color: #81476d;" cellpadding="10">';
$message .= "<tr><h3 style='Color: #81476d'>General: </h3></tr>";
$message .= "<tr><td><strong>Full Name: </strong></td><td>" . $fullname . "</td></tr>";
$message .= "<tr><td><strong>Email Address: </strong></td><td>" . $email . "</td></tr>";
$message .= "<tr><td><strong>Subject: </strong></td><td>" . $Subject . "</td></tr>";

include_once(ABSPATH . WPINC . '/class-phpmailer.php');
$pmail = new PHPMailer();
$pmail->From = strip_tags($email);
$pmail->FromName = $fullname;
$pmail->Subject = $subject;
$pmail->IsHTML(true);
$pmail->AddAddress(get_option('admin_email'), 'Simon');
$pmail->AddAttachment($_FILES['Photo']['tmp_name'], $_FILES['Photo']['name']);
$pmail->Body = $message;
if($pmail->Send()) my_contact_form_generate_response("success", $message_sent);
          else my_contact_form_generate_response("error", $message_unsent);
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大