LoginSignup
0
0

More than 3 years have passed since last update.

9/21 成果報告

Posted at

formタグについて

ログイン機能の実装の際など、ユーザーの入力情報をサーバーに送る際には、formタグを用いる。

index.html
  <body>
  <form action="index.php" method="post">
      <p>名前:<input type="text" name="name"></p>
      <p>パスワード:<input type="text" name="password"></p>
      <input type="submit">
    </form>
  </body>

各属性の説明

  • action・・・送信ボタンを押した後の遷移ファイルを指定
  • method・・・postかgetを用途によって指定。

送信ボタンを押すと、formタグで囲まれた部分がサーバーに送信される。
この時、name属性を識別子とする連想配列で送信されるので、それをphpで扱う。

index.php
<?php
$name = $_POST['name'];
$password = $_POST['password'];
echo "お名前は".$name."で、パスワードは".$password."です。";
 ?>
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