$connection->query($sql); } if ($_SERVER["REQUEST_METHOD"] == "POST") { $form_string = null; $form_error = array(); if (!isset($_POST['field_type'])) { $form_error['nofields'] = "Form needs atleast one form field to be generated."; } else { $form_id = null; if (isset($_SESSION['user_email'])) { $form_id = create_form($_POST['form_name'], date("Y-m-d H:i:s"), $_SESSION['user_email'], $connection); } $form_string = "<h2>{$_POST['form_name']}</h2><form>"; $form_string .= "<table>"; for ($i = 0; $i < count($_POST['field_type']); $i++) { $form_string .= get_form_string($i); if ($form_id) { save_field($form_id, $_SESSION['user_email'], $_POST['field_type'][$i], $_POST['field_title'][$i], $_POST['field_name'][$i], $i + 1, $_POST['field_options'][$i], $connection); } } $form_string .= "</table>"; $form_string .= "</form>"; $_SESSION['form_title'] = $_POST['form_name']; $_SESSION['form_string'] = $form_string; } } ?> <?php require 'template/header.php'; require 'template/navigation.php';
return $string; } } if (isset($_GET['id']) and isset($_SESSION['user_email'])) { $sql = "SELECT * FROM `forms` WHERE `id` = {$_GET['id']} AND `users_email`= '{$_SESSION['user_email']}'"; $result = $connection->query($sql); $form_fields = null; if ($result->num_rows > 0) { $sql = "SELECT * FROM `forms_fields` WHERE forms_id = {$_GET['id']} ORDER BY `form_order`"; $form_fields = $connection->query($sql); } $form = $result->fetch_object(); $form_string = "<h2>{$form->form_title}</h2><form>"; $form_string .= "<table>"; while ($form_field = $form_fields->fetch_object()) { $form_string .= get_form_string($form_field->fields_type, $form_field->field_title, $form_field->field_name, $form_field->options); } $form_string .= "</table>"; $form_string .= "</form>"; $_SESSION['form_title'] = $form->form_title; $_SESSION['form_string'] = $form_string; } require 'template/header.php'; require 'template/navigation.php'; ?> <?php if (isset($form_string)) { ?> <div class="container"> <div class="row">