試圖將recaptcha添加到我的php表單中,我從Google提供的示例php代碼開始。我插入下面的代碼,到form1.php:將php代碼插入html代碼截斷
<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>
不是看到captcha圖像的,我發現,即使提交按鈕消失。在瀏覽器中查看源代碼時,我發現代碼在行<td style="text-align: left;" colspan="2">
後被截斷。從php代碼開始,頁面上沒有顯示任何內容。
這不是將php代碼插入html的正確方法嗎?爲什麼在PHP代碼的開頭截斷html代碼?
你確定recaptchalib.php和這個form1.php在同一個目錄嗎? – Ron