doucaigai7176 2012-10-25 10:35
浏览 38
已采纳

iframe颜色框联系表单将不会提交,并且样式将不会在验证后保留

I'm trying to create a contact form in colorbox (overlay across the whole page) calling from an iframe. I got pretty much everything figured out except that the form won't submit and I lost the css style and everything after validation. What did I do wrong? Your help will be greatly appreciated. Thanks!!!

Here are the codes I have so far:

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>

colorbox-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";
}
    ?>

SYNTAX ERROR

$email-address=$_POST['email-address'];
$your-name=$_POST['your_name'];
$header. = 'Content-type: text/html; charset=iso-8859-1' . "
";    

$header.="From: " . $your-name <$email-address>."
";
  • 写回答

1条回答 默认 最新

  • douan4359 2012-10-25 10:42
    关注

    You have to use below code on sendmessages.php page you have used Post method so you have to get data using $_POST variable like this:

    UPDATE

    $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'."
    ";
    
    $header.='Content-type: text/html; charset=iso-8859-1'."
    ";    
    
    $header.="From: " . $your_name."<".$email_address.">"."
    ";
    $subject="Mail test";
    // Enter your email address
    $to ='mail@kitistproduction.com';
    $send_contact=mail($to,$subject,$message,$header);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 深度学习残差模块模型
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)