jQuery对话框,php表单 [英] jQuery dialog box, php form

查看:372
本文介绍了jQuery对话框,php表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个对网页打开的对话框。

i have a dialog box that opens on pageload for a site.

script type="text/javascript">
$(function() {
    $('#dialog-message').dialog({
        modal: 'true',
        width: '400'
    });
});

</script>

这会拉出一个包含:

<div id="dialog-message" title="Free Jiu Jitsu Session at Alliance">
          <!--#include virtual="/includes/guest.php" -->

guest.php有一个非常由页面本身处理的小表单:

guest.php has a very small form that is processed by the page itself:

    <?php
$dbh=mysql_connect //login stuff here       
                if (isset($_POST['submit'])) { 

                if (!$_POST['name'] | !$_POST['email']) 
                {
                echo"<div class='error'>Error<br />Please provide your Name and Email Address so we may properly contact you.</div>";
                }
                else
                {
                $age = $_POST['age'];   
                $name = $_POST['name'];
                $gender = $_POST['gender'];
                $email = $_POST['email'];
                $phone = $_POST['phone'];
                $comments = $_POST['comments'];

                $query = "INSERT INTO table here (age,name,gender,email,phone,comments)
                VALUES ('$age','$name','$gender','$email','$phone','$comments')";

                mysql_query($query);

                mysql_close();

                $yoursite = "my site here";
                $youremail = $email;

                $subject = "Website Guest Contact Us Form";
                $message = "message here";

                $email2 = "send to email address";

                mail($email2, $subject, $message, "From: $email");

                echo"<div class='thankyou'>Thank you for contacting us,<br /> we will respond as soon as we can.</div>";

                }
                }
                ?>

                <form id="contact_us" class="guest" method="post" action="/guest.php" >
                    <fieldset>
                        <legend>Personal Info</legend>
                            <label for="name" class="guest">Name:</label>
                            <input type="text" name="name" id="name" value="" /><br>

                            <label for="phone" class="guest">Phone:</label>
                            <input type="text" name="phone" id="phone" value="" /><br>

                            <label for="email" class="guest">Email Address:</label>
                            <input type="text" name="email" id="email" value="" /><br>

                            <label for="age" class="guest">Age:</label>
                            <input type="text" name="age" id="age" value="" size="2" /><br>

                            <label for="gender" class="guest">Sex:</label>
                            <input type="radio" name="gender" value="male" /> Male
                            <input type="radio" name="gender" value="female" /> Female<br />
                    </fieldset>

                    <fieldset>
                       <legend>Comments</legend>     

                            <label for="comments" class="guest">Comments / Questions:</label>
                            <textarea id="comments" name="comments" rows="4" cols="22"></textarea><br>

                            <input type="submit" value="Submit" name="submit" /> <input type="Reset" value="Reset" />

                    </fieldset> 
                </form>

问题是,窗体动作的路径不起作用,因为此对话框位于index.html页面的网站,如果我把绝对路径,它不处理...

Problem is, that the path of the form action does not work, becasue this dialog box is on the index.html page of the site, and if i put the absolute path, it doesnt process...

我有另一个联系我们的页面上运行,所以我知道它的作品,但是对话框,似乎已经困扰了我...

i have this functioning on another contact us page, so i know it works, but wit the dialog box, it seems to have stumped me...

我该怎么办?

推荐答案

我认为你最好的(最简单的)赌注实际上是将表单发布到一个包装页面(thanks.php或者你有什么),后者又包含了guest.php代码。

I think your best (simplest) bet is actually to post the form to a wrapper page (thanks.php or what have you) which in turn includes the guest.php code.

您现在的方式,您将结果发布到include / guest.php文件,其中没有明显的HTML修饰。听起来你可能希望结果以一些AJAX-y方式加载到对话框中?

The way you've got it now, you'll post your results to the include/guest.php file, which has no apparent HTML dressing around it. It sounds like you may expect the result to load into the dialog box in some AJAX-y manner?

这篇关于jQuery对话框,php表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆