2011-03-25 11:42
浏览 64


I have developed a simple php application. This application contains one html file and one php file. What i am doing is when user selects two dates and enters his/her email addresss, i am calling my php file which is sending the mail to entered email id.

It sends the mail correctly. But the problem is its not showing me the status whether mail is sent or not. I am using alert.

This is my html file :

<link rel="stylesheet" href="ui.all.css" type="text/css" media="screen" />
        <label>Leave Application</label><br/>
    From <input id="date" type="text"  name="ndate" /><div id="d1"></div><br/>
        To <input id="date1" type="text"  name="ndate1" /><div id="d2"></div><br/>
        Email To <input type="text" id="UserEmail" name="userEmail" onkeyup=""/><br/>
        <input type="submit" id="btn_submit" value="Send" onclick="" />

    <span id="d"></span>

    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src=""></script>

        <script type="text/javascript">
                $("#date").datepicker({ showOn: 'button', buttonImageOnly: true, buttonImage: 'Images/icon_cal.png' });
                        $("#date1").datepicker({ showOn: 'button', buttonImageOnly: true, buttonImage: 'Images/icon_cal.png' });


                     var hasError = false;
                        var dt1=$("#date").val();
                     var dt2=$("#date1").val();
                     var em=$("#UserEmail").val();

                      if(dt1 == '')
                            $("#d1").before('<span class="error"><font color="red">This Field Must not be empty.</font></span>');
                            hasError = true;

                        if(dt2 == '')
                            $("#d2").before('<span class="error"><font color="red">This Field Must not be empty.</font></span>');
                            hasError = true;

                        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

                        var emailaddressVal = $("#UserEmail").val();

                        if(emailaddressVal == '') {
                            $("#UserEmail").after('<span class="error"><font color="red">Please enter your email address.</font></span>');
                            hasError = true;
                        else if(!emailReg.test(emailaddressVal)) {
                            $("#UserEmail").after('<span class="error"><font color="red">Enter a valid email address.</font></span>');
                            hasError = true;
                        if(hasError == true) { return false; }

                        type: "GET",
                        url: "",                        
                        async: false,
                        data: "dt1="+dt1+"&dt2="+dt2+"&email="+em,
                        success: function(msg){


This is my php file :


        $msg="Respected Sir,

\tI will not be able to come to office from ".$dt1." to ".$dt2.". Please grant my leave";

        $pcsubject = 'Leave Application';
        $pcmessage = $msg;
        $pcheaders = ''."
" .
" .
                     'X-Mailer: PHP/' . phpversion();

        $isdone=mail($pcto, $pcsubject, $pcmessage, $pcheaders);

            echo "Mail Sent";
            echo "Please Try Again";
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • doutan3040 2011-06-01 03:55

    Dont know the same code is running for me now...

    解决 无用
    打赏 举报

相关推荐 更多相似问题