Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 使用php表单处理页面有时会在输出中包含HTML元素_Jquery_Html_Forms - Fatal编程技术网

Jquery 使用php表单处理页面有时会在输出中包含HTML元素

Jquery 使用php表单处理页面有时会在输出中包含HTML元素,jquery,html,forms,Jquery,Html,Forms,我正在使用Ajax向表单处理页面提交表单 它工作正常,但随机发送给用户的输出包括用于构造传出消息的部分HTML元素,或者在字母之间出现随机空格 下面是用于处理的表单代码 // Data Time Stamp for submission $submit_date = date("l jS F Y h:i:s A"); // Meeting Request Message Build code $message = '<html><body>'; $message

我正在使用Ajax向表单处理页面提交表单

它工作正常,但随机发送给用户的输出包括用于构造传出消息的部分HTML元素,或者在字母之间出现随机空格

下面是用于处理的表单代码

    // Data Time Stamp for submission
$submit_date = date("l jS F Y h:i:s A");

// Meeting Request Message Build code
$message = '<html><body>';
$message .= '<br>';
$message .= '<table class="emailform" rules="all" style="margin:10px auto; border:1px solid #f8981d; table-layout: fixed;">';
$message .= "<tr style='background: #f8981d; color:#FFFFFF' ><td colspan='2' class='centered-cell'><strong><center>Meeting Request Form</center></strong></td></tr>";
$message .= "<tr><td><strong>Name:</strong></td><td>" . $emp_Name . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . $emp_Email . "</td></tr>";
if($req_Name != "") {
    $message  .= "<tr><td><strong>Requestor's Name:</strong></td><td>" . $req_Name . "</td></tr>";
}
if($req_Email != "") {
    $message  .= "<tr><td><strong>Requestor's Email:</strong></td><td>" . $req_Email . "</td></tr>";
}
$message .= "<tr><td><strong>Function:</strong> </td><td>" . $meeting_Function . "</td></tr>";
$message .= "<tr><td><strong>Setup Date & Time:</strong> </td><td>" . $borrow_Date . " " . $time_Setup ."</td></tr>";
$message .= "<tr><td><strong>Start Date & Time:</strong> </td><td>" . $borrow_Date . " " . $time_Actual ."</td></tr>";
$message .= "<tr><td><strong>Return Date & Time:</strong> </td><td>" . $return_Date . " " . $end_Time ."</td></tr>";
$message .= "<tr><td><strong>Location:</strong> </td><td>" . $Loc ."</td></tr>";

if($contact_Number != "") {
    $message .= "<tr><td><strong>Contact Number:</strong></td><td>" . $contact_Number . "</td></tr>";   
}

if($hw_LcdProjectorQty != "") {
    $message  .= "<tr><td><strong>Projector</strong></td><td>Quantity: " . $hw_LcdProjectorQty . "</td></tr>";
}

if($hw_LaptopQty != "") {
    $message  .= "<tr><td><strong>Laptop</strong></td><td>Quantity: " . $hw_LaptopQty . "</td></tr>";
}

if($hw_WiredMouseQty != "") {
    $message  .= "<tr><td><strong>Wired Mouse</strong></td><td>Quantity: " . $hw_WiredMouseQty . "</td></tr>";
}

if($hw_WiredKeyboardQty != "") {
    $message  .= "<tr><td><strong>Wired Keyboard</strong></td><td>Quantity: " . $hw_WiredKeyboardQty . "</td></tr>";
}

if($hw_iPadQty != "") {
    $message  .= "<tr><td><strong>iPad</strong></td><td>Quantity: " . $hw_iPadQty . "</td></tr>";
}

if($hw_RemoteMouseQty != "") {
    $message  .= "<tr><td><strong>Remote Mouse</strong></td><td>Quantity: " . $hw_RemoteMouseQty . "</td></tr>";
}

if($hw_PowerStripQty != "") {
    $message  .= "<tr><td><strong>Power Strip</strong></td><td>Quantity: " . $hw_PowerStripQty . "</td></tr>";
}

if($hw_HandMicQty != "") {
    $message  .= "<tr><td><strong>Hand Microphone</strong></td><td>Quantity: " . $hw_HandMicQty . "</td></tr>";
}

if($hw_LapelMicQty != "") {
    $message  .= "<tr><td><strong>Lapel Microphone</strong></td><td>Quantity: " . $hw_LapelMicQty . "</td></tr>";
}

if($hw_MediaCart != "") {
    $message  .= "<tr><td><strong>Media Cart</strong></td><td>Quantity: " . $hw_MediaCart . "</td></tr>";
}

if($hw_PolyComPhone != "") {
    $message  .= "<tr><td><strong>Polycom Conference Phone</strong></td><td>Quantity: " . $hw_PolyComPhone . "</td></tr>";
}

if($Applications != "") {
    $message  .= "<tr><td><strong>Applications Requested:</strong></td><td>" . $Applications . "</td></tr>";
}

if($Comment != "") {
    $message  .= "<tr><td><strong>Comments/Special Instructions:</strong></td><td>" . $Comment . "</td></tr>";
}

$message .= "<tr style='background: #f8981d;  color:#FFFFFF'><td><strong>Status:</strong> </td><td>Request Submitted</td></tr>";
$message .= "</table>";
$message .= "</body></html>";

// send mails
$sentMail = @mail($to_Email, $subject, $message, $headers, $ical);

if(!$sentMail)
{
    $output = json_encode(array('type'=>'error', 'text' => 'Could not send mail! Please check your PHP mail configuration.'));
    die($output);
} else {
    $output = json_encode(array('type'=>'message', 'text' => 'Your Request has been sent. Thank you'));     
    die($output);
}
}
我确实看到其他随机字符的显示空格、撇号、元素标记(如td)也随机显示在输出中。我有一种感觉,我可以缓冲它,以防止这些输出工件,但我通过示例学习得最好


谢谢,

在笔记本电脑之后,代码中没有:,所以不能有。而数量中间的空间是非常神秘的。 我不知道这是否正确,但如果在笔记本电脑:schould之后,代码必须是这样的:

[...]<tr><td><strong>Laptop:</strong></td><td>Quantity[...]
我想说的另一件事是,如果:是正确的,试试这个:

[...]<tr><td><strong>Projector Quantity:</strong></td><td>[...]

也许空间消失了

电子邮件客户端可能正在解释它自己的断行机制,因为它认为源代码都是一行。尝试在语句末尾添加一些换行符,例如替换结束td和行,如:\r\n;我会试试这个,看看是否有用。现在我想起来了。如果是这样的话,我每次都会看到问题。然而,这完全是随机的。有时电子邮件被正确地输出,而另一些时候,它会引入诸如HTML标记或随机空格之类的工件。我说10封邮件中有8封被发送。你有没有试着回显$message并查看DOM源代码,看看里面有没有什么时髦的东西?结果是一样的。在回显$message php变量时。在失败的尝试中,其中一个if语句的TD标记被输出。是的,我已经在代码中更正了这一点,并将其从原始问题中编辑掉。然而,这并不能解释为什么工件正在突破。最终,这将被视为Outlook中的电子邮件。
[...]<tr><td><strong>Projector Quantity:</strong></td><td>[...]