この内容は古いバージョンです。最新バージョンを表示するには、戻るボタンを押してください。
バージョン:2
ページ更新者:guest
更新日時:2026-06-10 15:51:00

タイトル: $_GET

この本文には実行可能なタグ等が含まれるため、安全のためHTMLソースとして表示しています。本文データは変更していません。

<p>クライアント&rarr;サーバへのデータ送信方法の一つ。</p>

<p>以下、HTMLフォームを送信する方法を記載する。</p>

<p><strong>HTMLのformタグ(method属性で&rdquo;<span style="color:#e74c3c">GET</span>&rdquo;指定、もしくは未指定)内のaction属性で、受信側のファイルを指定する。</strong></p>

<p><strong>受信側のファイルでは <span style="color:#e74c3c">$_GET[&lsquo;name属性名']</span> で送信データを受け取る。</strong></p>

<p>URLに送信データが記載される。</p>

<p>&nbsp;</p>

<p>以下、実装例。</p>

<p>【例】</p>

<p style="margin-left:40px"><strong>『注文画面 (index.php)』</strong></p>

<p style="margin-left:40px"><img alt="" src="/uploadImage/20170808180944_5803841.jpg" /></p>

<p style="margin-left:80px">URL:http://~/index.php</p>

<p style="margin-left:80px"><html></p>

<p style="margin-left:80px">&nbsp; &nbsp; <body></p>

<p style="margin-left:80px">&nbsp; &nbsp; &nbsp; &nbsp; <!-- フォーム通信を実行する --></p>

<p style="margin-left:80px">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#e74c3c"> <form method="GET" action="TestGet.php"></span></p>

<p style="margin-left:80px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input type="text" name="item"></p>

<p style="margin-left:80px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input type="submit" value="注文する"></p>

<p style="margin-left:80px">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#e74c3c"></form></span></p>

<p style="margin-left:80px">&nbsp; &nbsp; </body></p>

<p style="margin-left:80px"></html>&nbsp;&nbsp; &nbsp;</p>

<p style="margin-left:80px">&nbsp;</p>

<p style="margin-left:40px"><strong>『注文完了画面 (TestGet.php)』</strong></p>

<p style="margin-left:40px"><img alt="" src="/uploadImage/20170808180952_5039940.jpg" /></p>

<p style="margin-left:80px">URL:http://~/TestGet.php?item=カレーパン<br />
&nbsp;&nbsp; &nbsp;</p>

<p style="margin-left:80px"><html></p>

<p style="margin-left:80px">&nbsp; &nbsp; <body></p>

<p style="margin-left:80px">&nbsp; &nbsp; &nbsp; &nbsp; <?=<span style="color:#e74c3c">$_GET['item']</span> ?>の注文を承りました。 &nbsp; &nbsp; &nbsp; &nbsp;</p>

<p style="margin-left:80px">&nbsp; &nbsp; </body></p>

<p style="margin-left:80px"></html></p>

<p style="margin-left:80px">&nbsp;</p>