how to create function in cakephp code example

Example 1: setup cakephp

1. Add .htaccess
<IfModule mod_rewrite.c>
	RewriteEngine on
	RewriteRule ^$ webroot/ [L]
	RewriteRule (.*) webroot/$1 [L]
</IfModule>

2. Add Permission tmp, Vendor, Webroot
- Window Set permisson
- Linux Set chmod -R 777

Example 2: how to pass data cakephp from

// output, if you wanna get output same below array, you need to use name="Member[verify_code]" 
// name="Member[email]"  in form

Array(
    [Member] => Array   (
      [verify_code] => 123466
      [email] => [email protected]
      [lang] => zho
      [password] => 123
      [confirm_password] => 123
) )
  
  // cake php form
  <?=$this->Form->create('Member', array('role' => 'form')); ?>
  <fieldset>
  <?=$this->Form->input('lang', array('type' => 'hidden', 'value' => $lang, 'required'));?>

  <div class="form-group">
  <input type="hidden" name="Member[verify_code]" value="<?= isset($verify_code) && !empty($verify_code) ? $verify_code : ''; ?>" />
  </div>

  <div class="form-group">
  <input type="hidden" name="Member[email]" value="<?= isset($email) && !empty($email) ? $email : ''; ?>" />
  </div>

  <div class="form-group">
  <?=$this->Form->input('password', array('class' => 'form-control', 'placeholder' => __d('frontend', 'new_password'), 'label' => '', 'required')); ?>
  </div>
  </fieldset>
  <?=$this->Form->end(); ?>

Tags:

Php Example