如何在提交optin表单后显示javascript或php成功消息

如何在提交optin表单后显示javascript或php成功消息,javascript,php,jquery,html,forms,Javascript,Php,Jquery,Html,Forms,我在表单中使用自定义选项页面,当前表单的工作方式如下用户提交>页面刷新>我收到一封包含提交数据的电子邮件。 但是用户没有收到确认消息,因此大多数情况下,用户重新提交表单时认为它在第一次不起作用 我想在其中添加一条弹出/Javascript成功消息,或点击提交后,用户将被重定向到另一个页面 这是当前的表单代码 <div class="form fix "> <p class="form-text">Fill This Out and

我在表单中使用自定义选项页面,当前表单的工作方式如下用户提交>页面刷新>我收到一封包含提交数据的电子邮件。

但是用户没有收到确认消息,因此大多数情况下,用户重新提交表单时认为它在第一次不起作用

我想在其中添加一条弹出/Javascript成功消息,点击提交后,用户将被重定向到另一个页面

这是当前的表单代码

<div class="form fix ">
                    <p class="form-text">Fill This Out and See Your <br>Timeshare Report</p>
                    <form name="contactform" action="mail-script.php" method="POST">
                        <label for="fname">First Name:
                            <input type="text" name="fname" id="fname" />
                        </label><br>
                        <label for="lname">Last Name:
                            <input type="text" name="lname" id="lname" />
                        </label><br>
                        <label for="email">Email Address:
                            <input type="text" name="email" id="email" />
                        </label><br>
                        <label for="phone">Phone Number:
                            <input type="text" name="phone" id="phone" />
                        </label><br>
                        <label for="phone">Alternate Phone:
                            <input type="text" name="phone" id="aphone" />
                        </label><br>
                        <label for="resort">Resort Name:
                            <input type="text" name="resort" id="resort" />
                        </label><br>
                        <label for="amount">Amount Owed? $:
                            <input type="number" name="amount" id="amount" />
                            <p style="font-size: 12px !important;margin-top: -14px;padding-right: 30px;text-align:right;">
                            If Paid Off Leave Zero, Else Put Amount</p>
                        </label><br>
                        <div class="checkbox">
                            <div class="check-text fix">
                                <p>I'm Considering To</p>
                            </div>
                            <div class="check-one fix">
                                <input type="checkbox" name="call" id="" value="sell"/> Sell It <br>
                                <input type="checkbox" name="call" id="" value="buy"/> Buy It <br>
                                <input type="checkbox" name="call" id="" value="rent "/> Rent  It 
                            </div>
                            <div class="check-two fix">
                                <input type="checkbox" name="call" id="" value="cancel"/> Cancel Mortgage <br>
                                <input type="checkbox" name="call" id="" value="ownership"/> End Ownership <br>
                                <input type="checkbox" name="call" id="" value="give"/> Give It Back
                            </div>
                        </div>

                                                 <p class="captcha">
                            <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br>
                            <label for='message'>Enter the code above here :</label><br>
                            <input id="6_letters_code" name="6_letters_code" type="text"><br>
                            <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small>
                        </p>
                        <input id="submit" type="submit" value="" />
                        <p class="submit-text">Ensure all fields are completed and correct, allowing you more benefits, while preventing abuse of our data.</p>
                    </form>
                </div>
            </div>

填写此表格,然后查看您的分时度假报告

名字:
姓氏:
电邮地址:
电话号码:
备用电话:
度假村名称:
欠款?$:

如果已付清,则保留零,否则放入金额


我正在考虑

卖掉它
买它
出租 取消抵押贷款
最终所有权
还给我

“id='captchaimg'>
在此处输入上面的代码:

无法读取图像?单击以刷新

确保所有字段填写完整且正确,从而为您带来更多好处,同时防止滥用我们的数据

这是表单的在线url

**********************更新******************************

您可以通过下面的函数在表单提交事件上给出适当的消息。如果您在函数中提到,您甚至可以通过
event.preventDefault();
停止表单提交

$( "form" ).submit(function( event ) {
alert( "Handler for submit() called." );
window.location.href="another html page";
});

如果只需要一个普通的弹出按钮,可以执行以下操作:

$('form').on('submit',function(){
           alert('submitted');
});
如果你想用一种更奇特的方式做事,你可以使用。 您可以使用
id
成功向HTML添加隐藏的
div
,然后执行以下操作:

<span class="success">Thank's for submitting the form</span>

当用户单击您的url(如www.site.com/index.php)时,表单就会出现。当用户填写数据并单击提交url(如www.site.com/mail-script.php)时,我问您的mail-script.php代码在哪里

在这个文件底部,你可以添加这行代码

标题('Location:thankyou.php')

然后像这样创建自己的thankyou.php文件

<html>

<body>
       <h1>Mail delivery success. Touch you soon...</h1>
</body>
</html>

邮件发送成功。请尽快与您联系。。。

请使用php flash message功能。这意味着当表单提交成功时,通过在会话中设置flash message,在同一页面上显示flash message。请阅读php手册如何执行此操作。您可以在下一页中保留一个隐藏字段,我的意思是,表单提交成功后,它将重定向到某个页面,对吗?因此,在该页面中ep隐藏字段并在页面加载时设置它的值。您可以使用会话值设置它的值。就像表单发布及其成功后,设置会话变量并在下一页检查会话是否有值,如果有值,则为隐藏字段设置成功值,然后编写文档。准备好函数以检查隐藏字段值如果该值存在于该隐藏字段中,则显示成功消息div。我在('submit',function(){alert('submitted');})上将$('form')放在哪里;,在同一索引页或另一页中?是的,在有表单的同一页中。不起作用,我在表单之后添加了它,它也出现在页面上,但不起作用,然后我将它添加到页面的末尾,它仍然不起作用,然后我将它添加到mailscript页面,在点击提交后,我得到一个空白页面。这是什么你对它有何期待?当你点击按钮时,难道你一点也没有得到警告吗?你能在你的问题文本中显示你是如何把脚本放在上面的吗?
<html>

<body>
       <h1>Mail delivery success. Touch you soon...</h1>
</body>
</html>