I have a html file (index.html) which when loaded calls a colorbox after 5 seconds. The colorbox opens another html file (popup.html) which has a form for users to submit details.
On submit the form calls a php file which generates and sends an email. Once sent a success message is displayed on popup.html.
// create email headers
$headers = 'From: '.$email_from."
".
'Reply-To: '.$email_from."
" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- success html -->
<div class="popup_message"><h2>Thank you for contacting us. We will be in touch with you very soon.</h2></div>
<?php
}
die();
?>
The issue i am having is that i am attempting to style the popup_message H2 element using a global CSS file (defined in both index.html and popup.html), however it does not style the output.
Do i need to be defining the file within the php file also ?
Here is my php file, i tried adding the HTML code around the DIV but this just prevented the success message from showing:
<?php
echo
if(isset($_POST['email'])) {
$mobile_error = "";
$email_to = "contactus@complete-models.com";
$email_subject = "7 Day free pass interest";
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['first_name']) || !isset($_POST['mobile']) || !isset($_POST['email']) ) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name']; // required
$mobile = $_POST['mobile']; // required
$email_from = $_POST['email']; // 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 />';
}
$mobile_exp = '[0-9]';
if(!preg_match($mobile_exp, $mobile)) {
$error_message .= 'The Mobile number you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
$email_message = "Form details below.
";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($first_name)."
";
$email_message .= "Mobile: ".clean_string($mobile)."
";
$email_message .= "Email: ".clean_string($email_from)."
";
// create email headers
$headers = 'From: '.$email_from."
".
'Reply-To: '.$email_from."
" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- success html below -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/screen_style.css" />
</head>
<body>
<div class="popup_message"><h2>Thank you for contacting us. We will be in touch with you very soon.</h2></div>
</body>
</html>
<?php
}
die();
?>
Yes, you need to be defining the CSS in the PHP file, too. In fact, the PHP document should contain fully formed HTML, which is to say it should include: <html>
, <head>
and <body>
tags.
This is because the PHP file is its own separate file, just like index.html and popup.html.