[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/wepay/demoapp/ -> openaccount.php (source)

   1  <?php
   2  require  './_shared.php';
   3  ?>
   4  <h1>WePay Demo App: Open Account</h1>
   5  <a href="index.php">Back</a>
   6  <br />
   7  
   8  <?php
   9  if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  10      if (isset($_POST['account_name']) && isset($_POST['account_description'])) {
  11          // WePay sanitizes its own data, but displaying raw POST data on your own site is a XSS security hole.
  12          $name = htmlentities($_POST['account_name']);
  13          $desc = htmlentities($_POST['account_description']);
  14          try {
  15              $wepay = new WePay($_SESSION['wepay_access_token']);
  16              $account = $wepay->request('account/create', array(
  17                  'name' => $name,
  18                  'description' => $desc,
  19              ));
  20              echo "Created account $name for '$desc'! View on WePay at <a href=\"$account->account_uri\">$account->account_uri</a>. See all of your accounts <a href=\"accountlist.php\">here</a>.";
  21          }
  22          catch (WePayException $e) {
  23              // Something went wrong - normally you would log
  24              // this and give your user a more informative message
  25              echo $e->getMessage();
  26          }
  27      }
  28      else {
  29          echo 'Account name and description are both required.';
  30      }
  31  }
  32  ?>
  33  
  34  <form method="post">
  35      <fieldset>
  36          <legend>Account Info</legend>
  37  
  38          <label for="account_name">Account Name:</label><br />
  39          <input type="text" id="account_name" name="account_name" placeholder="Ski Trip Savings"/>
  40  
  41          <br /><br />
  42  
  43          <label for="account_description">Account Description: </label><br />
  44          <textarea name="account_description" rows="10" cols="40" placeholder="Saving up some dough for our ski trip!"></textarea>
  45  
  46          <br /><br />
  47  
  48          <input type="submit" value="Open account" />
  49      </fieldset>
  50  </form>


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1