i'm doing this on my site with the following code:
- <div id="contact" class="comments">
- <form id="contactform" method="POST" action="/ajax/">
- <h1>Contact Tentonaxe.com</h1>
- <input type="hidden" name="method" value="contactEmail" />
- <label for="name">Name</label><input type="text" id="stuff" name="stuff" class="stuff" /><input type="text" id="name" name="name" maxlength="20" /><br /><br />
- <label for="email">Email Address</label><input id="email" type="text" name="email" maxlength="75" /><br /><br />
- <label for="website">Website</label><input id="website" type="text" name="website" maxlength="75" /><br /><br />
- <label for="content-comment">Content</label><textarea id="content-comment" name="content"></textarea><br />
- <div class="note">Limit: 500 characters. All xml/html tags will be converted to plain text.</div><br />
- <input type="submit" value="Submit" />
- </form>
- </div>
- <script>
- $(document).ready(function(){
- $('#contactform').submit(function(){
- var $f = $(this);
- $.ajax({
- url: $f.attr('action'),
- type: $f.attr('method'),
- data: $f.serializeArray(),
- success: function(){
- $f.parent().html('<div class="thankyou">Thank you!</div>');
- }
- });
- return false;
- });
- });
- </script>
and i'm handling the dialog with a plugin called Boxy, however, this form will work in a jqueryUI dialog aswell.
serverside, you just accept the form fields and send an email with them. I dont do much php, so i cant help you with that part. you can see it in action at www.tentonaxe.com, just click on contact at the top.
the input with an ID and Class of "stuff" is my honeypot captcha, the idea behind it is to require that it be blank before sending any emails. The purpose of that is spam bots like to fill in all the fields, so if it fills in the stuff input, the i dont send the email on the server-side, but get rid of the form asif it was successful.