function commentform($pageid)
{
    //global $session;
    $process = new ProcessForm();
    $validate = $process::validate();
    $postcomment = new Table("Comments");
    //Process Page Form
    if ($process->submitForm()) {
        /*@setting validation rules*/
        $required = array("name", "comment");
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_requiredFields($required));
        $massage = $process->message("Comment has been successfully submmited.");
        //$sucessmsg = $_REQUEST["msg"]=$massage;
        if ($process->successflag) {
            //put database table here
            $postcomment::$tablefields = array("Name" => $process->post("name"), "Comment" => $process->post("comment"), "Pageid" => $pageid);
            /*saved to database*/
            $postcomment->save();
            //echo "new recored was added with id=".$postcomment->lastInsertedId();
            //echo "<br> success happened and all fields are sent to database, Thank you ! :)";
        }
    }
    $form = new Form("commentform", filter_var($_SERVER['PHP_SELF']) . "?" . filter_var($_SERVER['QUERY_STRING']), "post");
    //Company;
    $form->startForm();
    $form->setFormField("", $form->addFormInfo("<h2>Comment Form</h2>"));
    //Page Title
    $form->setFormField($form->inputLabel("name", "*Name"), $form->inputField("text", "name", $process->post("name")), $validate->displayErrorField($process->errorinfo, "name"));
    // Page Content
    $form->setFormField($form->inputLabel("comment", "*Comment (HTML is not allowed)"), $form->textAreaField("comment", $process->post("comment"), 10, 45, 'placeholder="Type comment here"'), $validate->displayErrorField($process->errorinfo, "comment"));
    //Submit Form
    $form->setFormField(null, $form->inputField("hidden", "userid", $process->post("userid", $authorid = "")) . $form->inputField("submit", "submit", "Add Comment"));
    $form->endForm();
    return $form->DisplayFields($GLOBALS["form_labling"], $process->message);
}
 /**
  * Store a newly created resource in storage.
  * POST /table
  *
  * @return Response
  */
 public function store()
 {
     $table = new Table();
     $table->number = Input::get('number');
     $table->seats = Input::get('seats');
     $table->position = Input::get('position');
     $table->description = Input::get('description');
     $table->available = Input::get('available');
     if (Input::hasFile('file')) {
         Input::file('file')->move(public_path() . '/upload', Input::file('file')->getClientOriginalName());
         $table->image_url = '/upload/' . Input::file('file')->getClientOriginalName();
     } else {
         $table->image_url = '/upload/table_thumb.jpg';
     }
     $table->save();
     return Response::json(['data' => 'Table saved'], 200);
 }
Example #3
0
<?php

require 'modules/Table.inc';
include_once "function_random_string.php";
if (isset($_POST)) {
    if (isset($_POST['mobile']) && isset($_POST['email']) && isset($_POST['name'])) {
        $mobile = $_POST['mobile'];
        $name = $_POST['name'];
        $email = $_POST['email'];
        $password = "******" . random_string(4);
        $db = new Table('users');
        $id = (int) $db->getLastId("user_id") + 10000;
        $data = array("user_id" => $id, "username" => $mobile, "password" => $password);
        $db->save($data);
        $url = "http://darpan.incorelabs.com/mail/mail-sample.php";
        $sub = "Darpan app credentials";
        $msg = "Hi " . $name . "\nWelcome to Darpan(Reflection of Friendship)\n\nYour app credentials are:\nUsername: "******"\nPassword: "******"\n\nRegards\nDarpan";
        $data = array('msg' => $msg, 'sub' => $sub, 'id' => 1, 'mail_id' => $email);
        $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data)));
        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);
        echo $result;
    }
}
function categoryForm()
{
    //put contents here
    $process = new ProcessForm();
    $validate = $process::validate();
    $postdata = new Table("pagecategory");
    if ($GLOBALS["action"] == "editpgcate") {
        $postdata::$id = "Id=" . $GLOBALS["id"];
        $editcate = $postdata::findRow($postdata::$id);
        $category = $editcate->Category;
        $visible = $editcate->Visible;
        $position = $editcate->Position;
    } else {
        $category = "";
        $visible = "";
        $position = "";
    }
    if ($process->submitForm()) {
        /*@setting validation rules*/
        $required = array("category");
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_requiredFields($required));
        $check_invalidchars = array("category");
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_invalidChars($check_invalidchars));
        $requiredlen = array("category" => 30);
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_FieldLength($requiredlen));
        $selectedindex = array("position" => "--Select Menu Position--");
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_selectField($selectedindex));
        $process->message("category has been successfully submmited.");
        if ($process->successflag) {
            //echo "success happened and all fields are sent to database, Thank you ! :)";//
            $postdata::$tablefields = array("Category" => $_POST["category"], "Position" => $_POST["position"], "Visible" => $_POST["visible"]);
            $postdata->save();
        }
    }
    $form = new Form("sitenavform", $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'], "post", "enctype=\"application/x-www-form-urlencoded\"\n");
    //Company
    $form->startForm();
    $form->setFormField("", $form->addFormInfo("<p>" . GenerateUrl::buildLink(".", "dashboard.php", "&laquo;Back to Sammary Page", "action=view,target=managesite") . "</p>" . "<h2>Use this form to add new page category.</h2><p>Required Fields are labelled with asterics (*)<hr/>"));
    //Category
    $form->setFormField($form->inputLabel("category", "*Category Name"), $form->inputField("text", "category", $process->post("category", $category)), $validate->displayErrorField($process->errorinfo, "category"));
    //Position
    $cateposition = function () {
        $getposition = new Table("sitemenu");
        $position_options = $getposition::findAllRecords("ORDER BY Id ASC");
        foreach ($position_options as $opt) {
            $options[0] = "--Select Menu Position--";
            $options[$opt->Position] = $opt->Nav_name;
        }
        return $options;
    };
    $form->setFormField($form->inputLabel("position", "*Menu Position"), $form->selectOptions("position", $cateposition(), $process->post("position", $position)), $validate->displayErrorField($process->errorinfo, "position"));
    //Radio for Visible//
    $form->setFormField($form->inputLabel("visible", "Menu Visibility"), $form->radioButton("Yes", "visible", "Y", $process->post("visible", $visible) == "Y" ? true : false) . $form->radioButton("No", "visible", "N", $process->post("visible", $visible) == "N" ? true : false));
    //Submit Form//
    $form->setFormField(null, $form->inputField("submit", "send", "Save"));
    $form->endForm();
    return $form->DisplayFields($GLOBALS["form_labling"], $process->message);
}