3
3

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 5 years have passed since last update.

[メモ] confirmなどに使えるpost処理

Posted at

POSTの値を保持する処理の一例。
メールフォームなどに使えるかも。

post.php
$array_post = array('subject','name','mail','message');
foreach($array_post as $value) {
    $post -> $value = isset($_POST[$value]) ? $_POST[$value] : null;
    $html -> $value = htmlentities($post->$value);
}

print <<<HTML
<form action="send.php" method="post">
    件名:<br>
    <input type="text" name="subject" size="30" value="{$html->subject}"><br>
    送信者名:<br>
    <input type="text" name="name" size="30" value="{$html->name}"><br>
    メールアドレス:<br>
    <input type="text" name="mail" size="30" value="{$html->mail}"><br>
    本文:<br>
    <textarea name="message" cols="30" rows="5">{$html->message}</textarea><br>
    <br>
    <input type="submit" value="送信する">
</form>
HTML;
3
3
2

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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?