<?php header('Content-Type: text/html; charset=utf-8');?>
<?php 


include("cnf.php");?>
<?php include("selects.php");$queries = new DatabaseFunctions($db5);?>
<?php


if(isset($_POST['newcast']) && 
   isset($_POST['p3']) 
  ){

$newcast = $_POST['newcast'];
$p3 = $_POST['p3'];
  
$newcast= json_decode($newcast,true);		
if(sizeof($newcast) > 0){

$newcast = $newcast[0];
$nam  =  iconv( "UTF-8", "Windows-1256",$newcast['nam'] );
$adr  =  iconv( "UTF-8", "Windows-1256",$newcast['adr'] );
$tel  =  iconv( "UTF-8", "Windows-1256",$newcast['tel'] );
$usernam    =  iconv( "UTF-8", "Windows-1256",$newcast['usernam'] );
$password    =  iconv( "UTF-8", "Windows-1256",$newcast['password'] );	
	
$valdataCheck = $queries -> addUser("EXEC insert_new_cast_sp @nam = '$nam' , @adr = '$adr'  , @tel = '$tel' ,@usernam = '$usernam',@password='$password', @ucid = '$p3'");	

$res = json_decode($valdataCheck,true);
$res = $res[0]["newcast"];
$jsn = json_encode($res, JSON_UNESCAPED_UNICODE);
$jsn = '{"newcast":' . $jsn . '}';
echo $jsn;  	
	
}else{
echo "خطا در ارسال اطلاعات از سمت کاربر";
}

}else{

exit("Direct access not permitted.");  
}
 

?>
