Link to home
Start Free TrialLog in
Avatar of DS928
DS928Flag for United States of America

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Robert Granlund
Robert Granlund
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DS928

ASKER

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?
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.
Avatar of DS928

ASKER

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
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&
Avatar of DS928

ASKER

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

@COBOLdinosaur

I try to pay it forward, since I'm the one always asking for help!
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&