0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

お問合せページを作成する

Posted at

formタグ

問い合わせフォームを作成する際は、HTMLのformタグを利用する。
action属性にはデータを渡す先のURLを指定します。
method属性は値の送信の方法で、「get」と「post」のどちらかを指定します。getの場合は送信される値がURLに表示され、postの場合はURLに表示されない

formタグ
<form action="URL" method="[get]or[post]">

<!-- ここにフォームの内容を書き込んでいく-->

</form>

テキストボックスを作る

inputタグ

<input type="text" name="email">でテキストの入力欄を作成する。
name属性は、入力データに名前をつけるようなもの
inputタグに閉じタグはない

textareaタグ

<textarea name="content"></textarea>
複数行のテキスト入力欄の作成時に使用する。
name属性の用途は、inputタグの時と同様。
閉じタグが必要。

inputタグとtextareaタグの使用イメージ
<form action="URL" method="[get]or[post]">

    <input type="text" name="email">

    <textarea name="content"></textarea>

</form>

submitタグ

送信ボタン用のタグ。input type = "submit"value属性でボタンに表示させる文字を決めることができる。

submitタグ
<input type = "submit" value = "送信">

formの内容を受け取る

formの内容を受け取るには、$_POSTを使用
$_POSTは連想配列になっており、name属性で指定した値を入れることで、送信された値を受け取ることができる

$_POST

//前提
form action="URL" method="[get]or[post]">

    <input type="text" name="email">

    <textarea name="content"></textarea>

</form>

//上記formから送信された値を取り出して出力
echo $_POST[email];
echo $_POST[content];

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?