dsvd407787736 2016-10-19 09:33
浏览 71

将自己的php联系表单添加到wordpress

i created a website and i'm just beginning with content management, so i installed wordpress with xampp and now adding everything that i made to the wordpress server. the only problem that came up is that i have a regular html formular with an action added that starts the php file when the user sends me the email which works offline. now i copied everything over and i don't get anything. it just sends me to another page without any content in it. so now my question is how do i tell wordpress to start the php file, when the user clicks on submit, send me the email and redirect the user to a success page.

  • 写回答

1条回答 默认 最新

  • dongmu2026 2016-10-19 10:01
    关注

    You can check for the submit value and send the email:

    A simple form:

    <form action="<?php echo site_url(); ?>" method="POST">
        <input type="text" name="some_field">
        <input type="submit" name="sendmail" value="1">
    </form>
    

    Add this to your functions.php:

    if ( isset( $_POST['sendmail'] ) ) {
    
        // here the code to send the mail
        wp_mail( ... );
    
        // redirect to a specific page
        wp_redirect( site_url('email-confirm') );
        exit;
    }
    

    Usefull links: wp_mail(), wp_redirect()

    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法