tags:

views:

505

answers:

2

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>

this pulls up an include:

<div id="dialog-message" title="Free Jiu Jitsu Session at Alliance">
          <!--#include virtual="/includes/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>

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...

what should i do?

A: 

Try to separate code or use # in action attribute

Artic
A: 

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.

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?

LesterDove
Yes, i would like to keep the "thank you" in the same dialog box, is that not possible?
tony noriega
Sure it's possible, but you'll have to look into some type of AJAX solution -- something that, in a nutshell, sends your data to the server via asynchronous JavaScript and then updates the DIV with fresh HTML. Myriad tutorials exist online. My particular choice is to use the JQuery library. Google $.get()The server side include alone won't behave the way you want it to, as it all comes down to the browser as one response (page+server include.) Unless you just want to fake it and have your thanks.php wrapper page look and feel exactly like the original :-)
LesterDove
That may be the best option for me right now... faking it.thanks
tony noriega