jQuery dialog box, php form.
Posted
by tony noriega
on Stack Overflow
See other posts from Stack Overflow
or by tony noriega
Published on 2010-03-11T19:31:30Z
Indexed on
2010/03/11
19:34 UTC
Read the original article
Hit count: 478
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?
© Stack Overflow or respective owner