将php代码插入html-代码被截断

将php代码插入html-代码被截断,php,html,forms,Php,Html,Forms,我试图将Recaptcha添加到我的php表单中,我从Google提供的示例php代码开始。我在form1.php中插入了以下代码: <html> <body> <h3>You can use the following form to contact the author:</h3> <form action="send1.php" method="post" name="contactform"> <table wid

我试图将Recaptcha添加到我的php表单中,我从Google提供的示例php代码开始。我在form1.php中插入了以下代码:

<html>
<body>

 <h3>You can use the following form to contact the author:</h3>

<form action="send1.php" method="post" name="contactform">

<table width="450px">
<tbody>
<tr>
<td valign="top"><label for="first_name">First Name *</label></td>
<td valign="top"><input type="text" maxlength="50" name="first_name" size="30" /></td>
</tr>
<tr>
<td valign="top"><label for="last_name">Last Name *</label></td>
<td valign="top"><input type="text" maxlength="50" name="last_name" size="30" /></td>
</tr>
<tr>
<td valign="top"><label for="email">Email Address *</label></td>
<td valign="top"><input type="text" maxlength="80" name="email" size="30" /></td>
</tr>
<tr>
<td valign="top"><label for="telephone">Telephone Number</label></td>
<td valign="top"><input type="text" maxlength="30" name="telephone" size="30" /></td>
</tr>
<tr>
<td valign="top"><label for="comments">Comments *</label></td>
<td valign="top"><textarea cols="30" maxlength="1000" name="comments" rows="6"></textarea></td>
</tr>
<tr>
<td></td>
<td style="text-align: left;" colspan="2">
<?php
          require_once('recaptchalib.php');
          $publickey = "GOkj44zG4SZKeo3PYMTmPYySzp7JPdq4";
          echo recaptcha_get_html($publickey);
?>
<input type="submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>

您可以使用以下表格联系作者:
名字*
姓*
电子邮件地址*
电话号码
评论*
我没有看到验证码图像,而是发现提交按钮也不见了。从浏览器查看源代码时,我发现代码在
行之后被截断。从php代码开始,页面上就没有显示任何内容

这不是将php代码插入html的正确方法吗?为什么html代码在php代码的开头被截断?

这是正确的方法

但如果您没有正确下载或安装所有文件,则可能会出现错误。这样的错误可能会立即停止脚本执行,因此还会阻止在脚本之后输出的静态html

脚本的语法似乎是正确的,而且显然有人试图运行它,这表明PHP也已经设置好了。因此,我猜测recaptchalib.php找不到,或者它包含其他找不到的文件


如果输出中没有任何错误,您可能需要检查错误日志,或启用错误输出,以便更好地了解正在发生的情况。

这是奇怪的。我已经重新检查并验证了文件recaptchalib.php是否存在于同一目录中,并且具有正确的文件名。我甚至尝试在require_once函数中添加完整路径。当我试图通过输入它的url直接运行它时,会调用recaptchalib.php。再次检查文档,显然您只需要一个文件。尽管如此,包括它可能会以某种方式导致问题,但如果没有正确的错误消息,它将是猜测;ini_集('display_errors','1')。我还查看了apache日志。它只显示了
[06/Jul/2013:21:51:15+0400]“GET/phpscript/form1http/1.1“200395”-“Mozilla/5.0(WindowsNT6.1;WOW64)AppleWebKit/537.36(KHTML,像Gecko)Chrome/27.0.1453.116 Safari/537.36”
,我想这意味着没有显示错误?我甚至通过bash中的
phpform1.php
执行了它。娜达,很奇怪。很抱歉,我没有clou。它可能是php.ini中定义的某个参数吗?您确定recaptchalib.php与此form1.php位于同一目录中吗?