I am trying to process a PHP form to stay on the same page in Wordpress but after I submit the form, everything works and it stays on the correct page, but the Wordpress Content Disappears. Is says "NOTHING FOUND" in the content area and it also has a search box.
I want the page to stay exactly like it was with the content except process my PHP Mailer and Echo Validation Message.
Here is my code:
<?php
if (!empty($_POST['submit'])) {
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$info = $_POST['info'];
$admin_email = get_option('admin_email');
$to = $admin_email;
$subject = 'Contact a Lawyer Form';
$msg = "YOUR INFORMATION:\n" .
"---------------------------------------… .
" Your Name: $name\n" .
" Your Phone: $phone\n" .
" Your Email Address: $email\n" .
" Additional Information: $info\n";
mail ($to, $subject, $msg, 'From: ' . $email);
/* Prepare autoresponder subject */
$respond_subject = "Your Information has been submitted and is being reviewed!";
/* Prepare autoresponder message */
$respond_message = "Hello $name!
Thank you for your submission! We will get back to you
as soon as possible! Your Information has been Submitted and is being reviewed
by our representatives! You will hear from an Associate as soon as possible!
Yours sincerely,
OUR NAME
www.OurDomain.com ";
/* Send the message using mail() function */
mail($email, $respond_subject, $respond_message, 'From: OurNAME');
}
?>
<div class="requestform">
<div class="formdiv">
Contact a Lawyer Today!
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" id="contactform">
<ol>
<li>
<label for="name">Full Name:</label>
<input id="name" name="name" class="text" style="width: 178px; height: 16px;" />
</li>
<li>
<label for="email">Your email:</label>
<input id="email" name="email" class="text" style="width: 178px; height: 16px;" />
</li>
<li>
<label for="company">Your Phone:</label>
<input id="company" name="phone" class="text" style="width: 178px; height: 16px;" />
</li>
<li>
<label class="brief1">Briefly Describe Your Legal Issue:</label>
<textarea cols="20" name="info" rows="3" style="width: 272px; height: 50px;"></textarea></li>
<li class="buttons">
<input type="image" name="submit" value="submit" alt="Submit Information" src="<?php echo get_option('siteurl') ?>/wp-content/themes/azure-basic/images/… height="42" width="272" />
<div class="clr"></div>
</li>
</ol>
</form>
<?php
if (!empty($_POST['submit'])) {
echo '<div class="disclaimerdiv-confirm">Your Message Has Been Submitted!</div>';
}
else {
echo '<div class="disclaimerdiv"><a href="' . get_option('siteurl') . '/divorce-attorneys-privacy-policy/">Dis… & Privacy Policy</a></div>';
}
?>

