Message in a Div

I have an contact form on a webpage.  There is a seperate PHP file that drives the form.  The problem is that I want the message to popup (I guess in a div) when the email is sent or not sent.  Right now a seperate page opens and that is not good.  How do I acomplish this?
Thank you.

PHP file
<?php
if(isset($_POST['email'])) {
	// EDIT THE 2 LINES BELOW AS REQUIRED
     $email_to = "ds@schuremediagroup.com";
	 $email_subject = "SMG Contact";
	 function died($error) {
     // your error code can go here
     echo "We are very sorry, but there were error(s) found with the form you submitted. ";
	 echo "These errors appear below.<br /><br />";
	 echo $error."<br /><br />";
	 echo "Please go back and fix these errors.<br /><br />";
	 die();    }
	 // validation expected data exists
	 if(!isset($_POST['name']) ||
	 !isset($_POST['email']) ||
	 !isset($_POST['comments'])) {
		         died('We are sorry, but there appears to be a problem with the form you submitted.');           }         			
				 $subject = $_POST['subject'];
				 $name = $_POST['name']; // required
				 $email_from = $_POST['email']; // required
				 $comments = $_POST['comments']; // required
				 $error_message = "";
				 $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
				 if(!preg_match($email_exp,$email_from)) {
					 $error_message .= 'The Email Address you entered does not appear to be valid.<br />';  }
					 $string_exp = "/^[A-Za-z .'-]+$/";  if(!preg_match($string_exp,$name)) {
						    }
							 if(strlen($comments) < 2) {
								 $error_message .= 'The Comments you entered do not appear to be valid.<br />';  }
								 if(strlen($error_message) > 0) {
									 died($error_message);  }
									 //$email_message = "\n\n";
									 function clean_string($string) {
										 $bad = array("content-type","bcc:","to:","cc:","href");
										 return str_replace($bad,"",$string);    }
										 $email_message .= "Subject: ".clean_string($subject)."\n";
										 $email_message .= "Name: ".clean_string($name)."\n";
										 $email_message .= "Email: ".clean_string($email_from)."\n";
										 $email_message .= "Comments: ".clean_string($comments)."\n";
										 // create email headers
										 $headers = 'From: '.$email_from;'
										 Reply-To: '.$email_from."\r\n" .'X-Mailer: PHP/' . phpversion();@mail($email_to, $email_subject, $email_message, $headers);  ?>
                                         <!-- include your own success html here -->
                                         Thank you for contacting us.
                                         <?php
                                         }
										 ?>

Open in new window


The html file link.

www.schuremediagroup.com
DS928Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rgranlundCommented:
The most simple way:
You need to take the PHP and place it on the same page as your form.  At the top, above the form. Then in the form action, change the action url from the current page to the page that has your form.  so the action url is the same url as the page you are on.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DS928Author Commented:
Thank you.  So far so good.  But I need it to appear in the center of the page.  Right now its in the upper left hand corner.  I would like it to be in the center of the page with an OK button on it.  How would I do this?
0
rgranlundCommented:
Place the PHP Complete or error message, within that div, where you want it to appear.  If you send me the complete code, I can help you sort it out.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

DS928Author Commented:
I've been playing with it.  I got the transparent box going and it's centered on the page Left and Right.  But it's not centered from the top.  Also it's pushing down the menu on the left.  It should lay over on top of everything.  'Ive attached the code.  Thank you so very much.
index.php
0
COBOLdinosaurCommented:
You need to give the box a style of position:absolute and use the top and left properties to position it.  To prevent inteference with other elements give it a z-index of 10.  No points for this, just adding in a little for the Expert you already have helping you.

@rgranlund,

Nice to see you working the Expert side of things. :^)

Cd&
0
DS928Author Commented:
Thank you.  This works.

#popup-wrapper
		{
			font:Arial, Helvetica, sans-serif;
			font-size:36px;
			font-style:normal;
			font-color;#FFF;
			line-height:100px;
			width:500px;
			height:100px;
			position:absolute;
			left:50%;
			top:50%;
			margin-left:-250px;
    		margin-top:-50px;
			z-index:10;
			border-style:solid;
 			border-color:#FFF;
			border-width:8px;
			background-color:#000000;
			opacity:0.6;
   			filter:alpha(opacity=60); /* For IE8 and earlier */
			padding:25px;
			border-radius-topleft: 20px; /* top left corner */
			border-radius-topright: 20px; /* top right corner */
			border-radius-bottomleft: 20px; /* bottom left corner */
			border-radius-bottomright: 20px; /* bottom right corner */
			border-radius: 20px 20px 20px 20px; /* shorthand topleft topright bottomright bottomleft */
			-webkit-border-top-left-radius: 20px;
			-webkit-border-top-right-radius: 20px;
			-webkit-border-bottom-left-radius: 20px;
			-webkit-border-bottom-right-radius: 20px;
			-moz-border-radius-topleft: 20px;
			-moz-border-radius-topright: 20px;
			-moz-border-radius-bottomleft: 20px;
			-moz-border-radius-bottomright: 20px;
		
		}

Open in new window

0
rgranlundCommented:
@COBOLdinosaur

I try to pay it forward, since I'm the one always asking for help!
0
COBOLdinosaurCommented:
Most of the top experts on the site start exactly that way, asking, then answering a couple, and before you realize it you discover you know more than you thought.

Good work.

Cd&
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.