10
10

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.

GoogleChartAPIのQRコード生成のURLを発行するphpスクリプトを組んでみた

Posted at
  • GoogleChartAPIを使うと簡単にQRコードが発行できて便利なんだけど都度URLエンコードなどがめんどくさいのでphpで画面を作ってみた
  • GoogleChartAPIについて http://ameblo.jp/kosado/entry-11432951365.html
  • 実はこれが初php

<!DOCTYPE HTML>
<html lang="ja">
  <head>
    <meta charset="utf-8">
    <title>QR code generator</title>
  </head>

  <body>
    <div>
      <form method="get">
        <table border="0">
          <tr>
            <td align="right"><b>Size</b></td>
            <?php $val = empty($_REQUEST["qr_size"]) ? "300" : $_REQUEST["qr_size"] ?>
            <td><input type="text" name="qr_size" size="3" maxlength="3" value="<?php echo $val ?>"></td>
          </tr>
          <tr>
            <td align="right"><b>URL</b></td>
            <?php $val = empty($_REQUEST["qr_url"]) ? "http://" : $_REQUEST["qr_url"] ?>
            <td><input type="text" name="qr_url" size="128" value="<?php echo $val ?>"></td>
          </tr>
          <tr>
            <td></td>
            <td>
              <input type="reset">
              <input type="submit">
            </td>
          </tr>
        </table>
      </form>
    </div>

    <hr width="50%" align="left">

    <?php if (!empty($_REQUEST["qr_size"])): ?>
      <div>
        <?php
          $url = urlencode($_REQUEST["qr_url"]);
          $qr_code_url = "https://chart.googleapis.com/chart?cht=qr&chs={$_REQUEST["qr_size"]}&chi={$url}";
        ?>
        <div><a href="<?php echo $qr_code_url ?>"><?php echo $qr_code_url ?></a></div>
        <div><img src="<?php echo $qr_code_url ?>"></div>
      </div>
    <?php endif ?>
  </body>
</html>
  • こんな画面になります
  • スクリーンショット 2014-04-22 13.01.33.png
10
10
3

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?