我正在尝试在彩色框中创建一个联系表单(覆盖整个页面),从iframe调用。我得到了很多东西,除了表单不会提交,我在验证后丢失了css样式和所有内容。我做错了什么?对你的帮助表示感谢。感谢!!!
以下是我目前的代码:
contactform.html
<body>
<form name="form1" method="post" action="sendmessages.php">
<input type="text" name="your_name" class="your-name" id="your-name" placeholder="your name">
<input type="text" name="email-address" class="email-address" id="email-address" placeholder="email address">
<textarea name="comments" class="comments" id="comments" placeholder="type your message here..."></textarea>
<input type="submit" value="submit" name="submit" class="submit">
</form>
的颜色框-k.css
#colorbox, #cboxOverlay, #cboxWrapper{
position:absolute;
top:0;
left:0;
z-index:9999;
overflow:hidden;
}
#cboxOverlay{
position:fixed;
width:100%;
height:100%;
}
#cboxContent{
position: relative;
overflow:hidden;
}
#cboxLoadedContent{
overflow:hidden;
}
#cboxLoadedContent iframe{
display:block;
position:absolute;
width:100%;
height:100%;
border:0;
}
#cboxOverlay{background:url(../images/overlay.png) repeat 0 0;}
#colorbox{}
#cboxContent{
position:fixed;
width:536;
height:409;
}
#cboxClose{
display:block;
position:absolute;
top:0px;
left:0px;
background:url(../images/close.png) no-repeat 0 0;
width:31px;
height:31px;
padding: 0px;
border: 0px;
text-indent:-9999px;
}
body {
background: url(../images/envelope.png) center no-repeat;
display: block;
position: absolute;
width: 536px;
height: 409px;
z-index:12;
position: relative;
margin:auto;
}
input[type=text] {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 10px;
background-color:rgb(255,255,255);
color: #787474;
padding-left: 10px;
width:194px;
height:24px;
position: absolute;
border-color: #000000;
border-width:2px;
border-style:solid;
}
.comments {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 10px;
background-color:rgb(255,255,255);
color: #787474;
padding: 10px 0 0 10px;
width:414px;
height:140px;
border-color: #000000;
border-width:2px;
border-style:solid;
position: absolute;
top: 150px;
left: 54px;
}
.your-name {
position: absolute;
top: 104px;
left: 54px;
}
.email-address {
position: absolute;
top: 104px;
left: 272px;
}
.submit {
width: 70px;
height: 24px;
background: url(../images/send-btn.png) center no-repeat;
position: absolute;
top: 338px;
right: 54px;
padding: 0px;
border: 0px;
text-indent:-9999px;
}
.submit:hover{
background: url(../images/send-btnr.png);
}
.submit:active{
background: url(../images/send-btn.png);
}
sendmessages.php
<?php
// Comments
$message="$comments";
// Mail of sender
$mail_from="$email-address";
// From
$header="from: $your-name <$mail_from>";
// Enter your email address
$to ='mail@kitistproduction.com';
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "Thank you!"
// Check, if message sent to your email
// display message "Thank you!"
if($send_contact){
echo "<p style='background: url(../images/envelope_sent.png) center no-repeat;
display:block;
position:relative;
top: -6px;
left: -6px;
width:536px;
height:409px;
z-index:12;
margin:auto;
padding:0px;'></p>";
}
else {
echo "ERROR";
}
?>
语法错误
$email-address=$_POST['email-address'];
$your-name=$_POST['your_name'];
$header. = 'Content-type: text/html; charset=iso-8859-1' . "\n";
$header.="From: " . $your-name <$email-address>."\n";
答案 0 :(得分:0)
您必须在sendmessages.php页面上使用以下代码 你使用了Post方法,所以你必须使用$ _POST变量来获取数据:
<强>更新强>
$comments=$_POST['comments'];
$email_address=$_POST['email-address'];
$your_name=$_POST['your_name'];
//echo "comments:".$comments."<br>";
//echo "email:".$email_address."<br>";
//echo "name:".$your_name."<br>";
//exit();
// Comments
$message=$comments;
$header='MIME-Version: 1.0'."\n";
$header.='Content-type: text/html; charset=iso-8859-1'."\n";
$header.="From: " . $your_name."<".$email_address.">"."\n";
$subject="Mail test";
// Enter your email address
$to ='mail@kitistproduction.com';
$send_contact=mail($to,$subject,$message,$header);