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>
キャプチャ画像が表示される代わりに、[送信] ボタンさえ消えていることに気付きました。ブラウザからソースコードを表示すると、行の後ろでコードが切り捨てられていることがわかりました<td style="text-align: left;" colspan="2">
。PHPコードの最初から、ページには何も表示されませんでした。
これは、php コードを html に挿入する適切な方法ではありませんか? html コードが php コードの先頭で切り捨てられているのはなぜですか?