<?php

include('functions.php');
include('db.inc.php');

if($round) {

	while (list($key, $val) = each($_POST)) {
		if ($key<>"id" && $key<>"Submit" && $key<>"round"){
			$insert_fields.=$key .", ";
			$insert_values.= "'". addslashes($val) . "', ";
			//$set.=$key ."='". addslashes($val) . "', ";
		}
	}

	$insert_fields=substr($insert_fields,0, strlen($insert_fields)-2);
	$insert_values=substr($insert_values,0, strlen($insert_values)-2);

	$stmt="INSERT INTO kk_vforma($insert_fields) VALUES($insert_values)";

	$mydb = new db();
	$result=$mydb->query($stmt);
	header("Location:a_vforma.php");

} else {

	$title="uj forma";

	include('header.inc.php');

	printf("<H3>Új forma hozzáadása</H3>");

	$mydb = new db();

	$link=$mydb->get_link();

	$result=mysql_list_fields("fordit", "kk_vforma", $link );

	for($field_index=0; $field_index<mysql_num_fields($result); $field_index++){
		$field_name=mysql_field_name($result, $field_index);
		$data[$field_name]="";
	}

/*
	while (list($key, $val) = each($data)) {
		echo "$key => $val<br>";
	}
*/


	generate_html_form('vforma', $data, $PHP_SELF);

	include('footer.inc.php');

}
?>
