LoginSignup
0
1

More than 5 years have passed since last update.

PHPフォーム作成で学んだこと(セッション)

Posted at

PHPフォーム作成で使ったもの(ツール)

エディタ:Atom 1.33.1 x64
ファイル共有ソフト:FileZilla
データベース確認:PhpMyAdmin
OS:Linux mint 19.1

セッションについて

以下のような挙動で実装した。

input.php

<?php
session_start();
?>



~~~~~CSS~~~~~

    <form method="post" action="confirmsankou.php">
    <div class="element_wrap">
    <label>学籍番号</label>
    <input type="text" name="your_number" value="<?php echo $_SESSION['your_number'];?>">
</div>

<div class="element_wrap">
<label>名前</label>
<input type="text" name="your_name" value="<?php echo ($_SESSION['your_name']);?>">
</div>
<div class="element_wrap">
<label>年齢</label>
<input type="text" name="your_old" value="<?php echo ($_SESSION['your_old']);?>">
</div>
    <div class="element_wrap">
    <label>備考</label>

    <textarea type="text" name="remarks" value="<?php echo ($_SESSION['remarks']);?>">
</textarea>
</div>  <input type="submit" name="btn_confirm" value="送信">
</form>

inputのフォームで受け取った値を、confirmsankou.phpに送信する。

confirmsankou.phpには「送信」ボタンと「戻る」ボタンがあり、セッション機能を実装していることによって、戻るボタンを押してもWebサーバ上に自動的に保存され、フォームには元の値が残ったままとなっている。

まとめ

今後もこのようなスーパーグローバル関数や、プログラミングを効率的に行えるスキルや関数などを身に着けていきたいと思う。

0
1
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
1