PHP code example of yuanqing / kontact

1. Go to this page and download the library: Download yuanqing/kontact library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yuanqing / kontact example snippets




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');
html
<body>
  <form action="mail.php" method="post" class="kontact">
    <div><label for="name">Name</label><input type="text" name="name" id="name" value=" echo @$_GET['data']['name'];