0

我尝试使用 php 和一个简单的表单发送电子邮件。代码上传: http ://webofdreams.ro/tests/basic%20template.html 发送电子邮件表单正在发送给朋友。问题是电子邮件未发送,单击后提交按钮消失。如果在按下取消后还有另一个按钮(比如说取消),则运行代码,但不发送电子邮件。在服务器上运行的代码非常简单:

<?php

$mailTo = $_POST['emailTo'];
$mailFrom = $_POST['emailFrom'];
$name = $_POST['name'];
$message = 'Your friend ' . $name .  'recommends this Web site: ';
$subject = $name . 'recommends Fine Maid';


mail($mailTo, $subject, $message);
echo "Mail Sent.";
?>

编辑:html:

   <html>
                           <ul>
                                <li><a href="#" title="">Call us</a>
                                    <div class="navLinks"> </div>
                                </li>
                                <li><a href="#">Visit our website</a>
                                       <div class="navLinks"> Content Here </div>
                                </li>
                                <li><a href="#">Email us</a>
                                       <div class="navLinks"> Content Here </div>
                                </li>
                                <li><a href="#">Send to a friend</a>
                                       <div class="navLinks"> 
                                            <form name="send-to-friend" id="form2" method="post" action="sendemail.php">
                                                <label for="name" class="blockItem">Your Name</label>
                                                <input type="text" class="blockItem" id="name" name="name" maxlength="60" size="30"/>
                                                <label for="emailFrom" class="blockItem">Your Email</label>
                                                <input type="text" class="blockItem" id="emailFrom" name="emailFrom" maxlength="60" size="30" />
                                                <label for="emailTo" class="blockItem">Your friend's email</label>
                                                <input  type="text" class="blockItem" id="emailTo" name="emailTo" maxlength="60" size="30" value="" />             
                                                <input class="button" id="submit" type="submit" value="Send Message"/>
                                                <!--<input  class="button"  type="submit" value="Cancel"  />-->

                                            </form>
                                       </div>
                                </li>
                            </ul>
    </html>

CSS:

.nav ul {
   list-style-type:none;}
.nav {
    float: right;
    line-height: 3.3em;
    }
.nav li {
    margin: 0 .5em;
    display: inline-block;
    }
.nav li a {
    color: #000;
    font-size: 1.1em;
    }
.navLinks {
    position: absolute;
    top: 3em;
    background: #2C75D8;
    padding: 0 5px;
    border: 2px solid #94afd3;
    -moz-box-shadow: 0 0 4px #fff;
    -webkit-box-shadow: 0 0 4px #fff;
    box-shadow: 0 0 4px #bbb;
    -webkit-border-radius: 7px;
    -moz-border-radius: 7px;
    border-radius: 7px;
    z-index: 1000;
    }       
form {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 14px;
    line-height: 1.5em;
    color: #ddd;
    text-decoration: none;
    padding: 1em;
    margin-bottom: 1em; 
    }   
label {
    margin: 10px 0 0 0;
    }
.blockItem {
    display: block;
    }
.error {
    display: block;
    color: #FF8080;
    }
.button {
    display: inline;
    margin-top: 10px;
    }   
span {
    color: #F00;
    }

jQuery:

    $(document).ready(function() {
        $('.commentContainer:odd').addClass('darker');

        $('#hideButton').click(function() {
        $(this).hide();     
        });

        $('.navLinks').hide();

        $(".nav a").on("click", function(e) {
            $(".navLinks").hide();
            $(this).siblings(".navLinks").show();
            e.preventDefault();
        });
});
4

0 回答 0