将值从 PHP 传递到 SimpleModal 联系表单

发布于 2024-09-10 05:54:55 字数 119 浏览 0 评论 0原文

将值从“索引”页面传递到 SimpleModal 演示联系表单的最简单方法是什么?例如,如果用户已登录并且其电子邮件地址存储在变量 $email 中,那么在演示联系表单中提供该信息的最直接方法是什么?

谢谢。

What is the simplest way to pass a value from the "index" page to the SimpleModal Demo Contact Form? For example, if a user is logged in and their email address is stored in the variable $email, what is the most straightforward way to have that info available in the Demo Contact Form?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞陪衬 2024-09-17 05:54:55

假设您想要的值不在表单中,这里有一种方法。

更新 onShow: 函数中的 contact.js:

...
}, function () {
    $('#contact-container .contact-loading').fadeIn(200, function () {

        var pt = PAGE_TITLE,
            aid = ARTILE_ID;

        $.ajax({
            url: 'data/contact.php',
            data: $('#contact-container form').serialize() + '&action=send&page_title=' + pt + '&article_id=' + aid,
            type: 'post',
            cache: false,
            dataType: 'html',
            success: function (data) {
                $('#contact-container .contact-loading').fadeOut(200, function () {
                    $('#contact-container .contact-title').html('Thank you!');
                    msg.html(data).fadeIn(200);
                });
            },
            error: contact.error
        });
    });
});
...

然后更新 function smcf_send() 函数中的 contact.php

...
// Set and wordwrap message body
$pt = isset($_POST["page_title"]) ? $_POST["page_title"] : "";
$aid = isset($_POST["article_id"]) ? $_POST["article_id"] : "";

$body = "From: $name\n\n";
$body .= "Page Title: $pt\n";
$body .= "Article ID: $aid\n\n";
$body .= "Message: $message";
$body = wordwrap($body, 70);
...

显然,您可以尝试细节,但这应该可以帮助您去。

-埃里克

Assuming the values you want are NOT in the form, here's a way to do it.

Update contact.js in the onShow: function:

...
}, function () {
    $('#contact-container .contact-loading').fadeIn(200, function () {

        var pt = PAGE_TITLE,
            aid = ARTILE_ID;

        $.ajax({
            url: 'data/contact.php',
            data: $('#contact-container form').serialize() + '&action=send&page_title=' + pt + '&article_id=' + aid,
            type: 'post',
            cache: false,
            dataType: 'html',
            success: function (data) {
                $('#contact-container .contact-loading').fadeOut(200, function () {
                    $('#contact-container .contact-title').html('Thank you!');
                    msg.html(data).fadeIn(200);
                });
            },
            error: contact.error
        });
    });
});
...

Then update contact.php in the function smcf_send() function

...
// Set and wordwrap message body
$pt = isset($_POST["page_title"]) ? $_POST["page_title"] : "";
$aid = isset($_POST["article_id"]) ? $_POST["article_id"] : "";

$body = "From: $name\n\n";
$body .= "Page Title: $pt\n";
$body .= "Article ID: $aid\n\n";
$body .= "Message: $message";
$body = wordwrap($body, 70);
...

Obviously you can play around with the details, but that should get you going.

-Eric

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文