Esempio n. 1
0
 /**
  * @runInSeparateProcess
  */
 public function testRedirect()
 {
     $data = array('name' => 'foo', 'email' => '*****@*****.**', 'message' => 'baz');
     $this->cb_args = array();
     $kontact = new Kontact($this->schema, $this->cb);
     $kontact->process($data, 'qux');
     $this->assertEquals(array('Location: qux?err=0&data%5Bname%5D=foo&data%5Bemail%5D=foo%40bar.com&data%5Bmessage%5D=baz'), xdebug_get_headers());
     $this->assertEquals(array(0, $data), $this->cb_args);
 }
Esempio n. 2
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once dirname(__DIR__) . '/php/src/Kontact.php';
use yuanqing\Kontact\Kontact;
$schema = array('name' => array('optional' => true, 'err' => 'Please enter your name'), 'email' => array('validate' => function ($input) {
    return filter_var($input, FILTER_VALIDATE_EMAIL);
}, 'err' => 'Please enter a valid email'), 'message' => array());
$cb = function ($err, $data) {
    if (!$err) {
        // do stuff with `$data`, eg. send mail($to, $subject, $message)
        return;
    }
};
$kontact = new Kontact($schema, $cb);
$kontact->process($_POST, 'example.php');