<?php
function registrovat()
{		
if (count($_POST)>0)
	{	// key => default value
	$keys = array(
		'email' => '',
		'heslo' => '',
		'hesloZnovu' => '',
		'jmeno' => '',
		'prijmeni' => '',
		'telefon' => '',
		'ulice' => '',
		'mesto' => '',
		'psc' => '',
		'captcha' => ''
		);
	$data = array();
	// read data
	foreach($keys as $key=>$value)
		{$data[$key] = isset($_POST[$key]) ? $_POST[$key] : $value;}
	// write data
	// !!! tady by mela byt kontrola dat, nez to zapises
	$spravceUzivatelu = new SpravceUzivatelu();
	$spravceUzivatelu->registruj($data); // nevim, proc tu nepredavas celou array
	// return data
	unset($data['heslo']);
	unset($data['hesloZnovu']);
	unset($data['captcha']);
	return json_encode($data);
	}
		
		if ($_POST)
		{
				
				$spravceUzivatelu = new SpravceUzivatelu();
				$spravceUzivatelu->registruj($_POST['email'],$_POST['heslo'],$_POST['hesloZnovu'],$_POST['jmeno'],$_POST['prijmeni'],$_POST['telefon'],$_POST['ulice'],$_POST['mesto'],$_POST['psc'],$_POST['captcha']);
									
						$email= $_POST['email'];
						$jmeno= $_POST['jmeno'];
						$prijmeni= $_POST['prijmeni'];
						$telefon= $_POST['telefon'];
						$ulice= $_POST['ulice'];
						$mesto= $_POST['mesto'];
						$psc= $_POST['psc'];
					
					$navraceno = array("id"=> 5 ,
						"email"=> $email,
						"jmeno"=> $jmeno,
						"prijmeni"=> $prijmeni,
						"telefon"=> $telefon,
						"ulice"=> $ulice,
						"mesto"=> $mesto,
		
						"psc"=> $psc);

			 
			
		}
		
		
			return json_encode($navraceno);
	
    }