如何在使用PHP的邮件功能将表单发送到邮件时在JavaScript中包含JavaScript / jQuery

时间:2015-08-17 11:06:27

标签: php jquery html

我想通过验证将表单发送到邮件。它正在工作,但我的验证不起作用。

这是我的代码:

$send_email = "ajinkyasmore@gmail.com";
$subject = "Testing Mail.!";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

$message = "<html><head>
        <link rel='stylesheet' type='text/css' href='welfare.mswarehousing.com/stylesheets/jquery.validate.css' />
        <link rel='stylesheet' type='text/css' href='welfare.mswarehousing.com/stylesheets/style.css' />
        <script src='welfare.mswarehousing.com/js/jquery-1.3.2.js' type='text/javascript'>
        </script>
        <script src='welfare.mswarehousing.com/js/jquery.validate.js' type='text/javascript'>
        </script>

        <script type='text/javascript'>         
            jQuery(function(){
                alert('inside js function');
                jQuery('#fname').validate({
                    expression: 'if (VAL == '') return false; else return true;',
                    message: 'field is null'
                });
              });               
        </script>
    </head>
    <form name='frame' id='main_frame' action='http://welfare.mswarehousing.com/thankyou.php' method='get' enctype='multipart/form-data'>
     <table width='250' cellspacing='0' cellpadding='0' border='0' align='left'>
     <tbody>
     <tr>
     <td>
     <table width='250' cellspacing='0' cellpadding='0' border='0' bgcolor='#c7ac77'>
     <tbody>
     <tr>
     <td width='15' height='15'>&nbsp;</td>
     <td>&nbsp;</td>
     <td width='15'>&nbsp;</td>
     </tr>
     <tr>
     <td>&nbsp;</td>
     <td>
     <table width='220' cellspacing='0' cellpadding='0' border='0' align='center'>
     <tbody>
     <tr>
     <td style='font-family: Calibri,Verdana; font-size: 25px; color: #ffffff; line-height: 26px;'><strong>Show Your Interest</strong></td>
     </tr>
     <tr>
     <td height='15'>&nbsp;</td>
     </tr>
     <tr>
     <td style='font-family: Arial,Verdana; font-size: 12px; color: #ffffff; line-height: 18px;'>Name</td>
     </tr>
     <tr>
     <td bgcolor='#ededed' height='28' style='font-family: Arial,Verdana; font-size: 12px; color: #666666; border: 1px solid #ffffff; background: #ffffff; padding-left: 5px;'>
     <input type='text' name='fname' size='26' id='fname' required/> 
     <input type='hidden' name='send_date' value='2015/08/08'>
     <input type='hidden' name='property_name' value='Drushtitechnet'>
     <input type='hidden' name='send_mail' value='$send_email'>
    </td>
    </tr>
    <tr>
    <td height='10'>&nbsp;</td>
    </tr>
    <tr>
    <td style='font-family: Arial,Verdana; font-size: 12px; color: #ffffff; line-height: 18px;'>Phone</td>
    </tr>
    <tr>
    <td height='28' style='font-family: Arial,Verdana; font-size: 12px; color: #666666; border: 1px solid #ffffff; background: #ffffff; padding-left: 5px;'><input type='text' name='contact'  size='26' required/></td>
    </tr>
    <tr>
    <td height='10'>&nbsp;</td>
    </tr>
    <tr>
    <td style='font-family: Arial,Verdana; font-size: 12px; color: #ffffff; line-height: 18px;'>Email</td>
    </tr>
    <tr>
    <td height='28' style='font-family: Arial,Verdana; font-size: 12px; border: 1px solid #ffffff; background: #ffffff; padding-left: 5px;'><input type='email' name='from'  size='26' required></td>
    </tr>
    <tr>
    <td height='15'>&nbsp;</td>
    </tr>
    <tr>
    <td valign='top'>
    <table width='220' cellspacing='0' cellpadding='0' border='0'>
    <tbody>
    <tr>
    <td height='40' style='font-family: Arial; font-size: 21px; text-align: center; background: #d24836; border: 1px solid #d24836; border-radius: 3px;'><a target='_blank' style='text-decoration: none; color: #ffffff; line-height: 40px; display: block;'><input type='submit' id='submit' value='I am Interested'></a></td>
    </tr>
    <tr>
    <td height='10'>&nbsp;</td>
    </tr>
    </tbody>
    </table>
    </td>
    </tr>
    </tbody>
    </table>
    </td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height='20'>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </tbody>
    </table>
    </td>
    </tr>
    <tr>
    <td height='20'>&nbsp;</td>
    </tr>
    </tbody>
    </table>
    </form></html>";

mail($send_email, $subject, $message, $headers);
?>

1 个答案:

答案 0 :(得分:1)

几乎所有电子邮件客户端都不会默认接受Javascript,并且具有非常好的(安全性)原因。

带领您的读者访问包含该表单的网站。