1
我有一個HTML文件(index.html),它在加載時在5秒後調用一個colorbox。 該colorbox打開另一個html文件(popup.html),其中有一個表單供用戶提交詳細信息。在外部php文件中創建的樣式HTML
提交表單調用一個生成併發送電子郵件的php文件。 popup.html上顯示一次成功的消息。
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'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();
?>
我遇到的問題是,我試圖使用樣式全局CSS文件(在index.html,然後popup.html定義)popup_message H2元素,但它不樣式的輸出。
我需要在php文件中定義文件嗎?
這裏是我的PHP文件,我嘗試添加周圍的DIV的HTML代碼,但是這只是從出阻止成功消息:
<?php
echo
if(isset($_POST['email'])) {
$mobile_error = "";
$email_to = "[email protected]";
$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._%-][email protected][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.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($first_name)."\n";
$email_message .= "Mobile: ".clean_string($mobile)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'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();
?>
對不起,這並沒有爲我工作。查看描述中添加的php文件。 – user3290060
你的DOCTYPE和標題標籤在哪裏......?下面是一個空的有效HTML文檔示例:https://shrib.com/4Bz7ODAfqs1e3ol還要確保CSS的URL是正確的,並且它在開發人員工具中不會出現404。 –