Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6667485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:56:17+00:00 2026-05-26T02:56:17+00:00

I created an input script. I write name and script post name into database.

  • 0

I created an input script. I write name and script post name into database. But I have error – ErrorException [ Notice ]: Undefined variable: result .

There is my controller:

class Controller_About extends Controller_Template{
    public function action_index()
    {
        if(!empty($_POST['name'])){
            $name = Model::factory('index')->insert_names($_POST['name']);;
            $result= $name;
        }
        $this->template->site_name = Kohana::$config->load('common')->get('site_name');
        $this->template->site_description = Kohana::$config->load('common')->get('site_description');
        $this->template->page_title = 'About';
        $this->template->content = View::factory('about/about')->set('result', $result);
        $this->template->styles[] = 'index/index';
    }
}

There is my view:

<form action="">
    <input type="text" name="name" />
</form>

And the is my model:

Class Model_Index Extends Model {

    public static function insert_names($name){
        $query = DB::query(DATABASE::INSERT, 'INSERT INTO names (name) VALUES (:name)')->parameters(array(':name' => $name));
    }
}

Where is the problem?

Edit #1

I edited the controller:

class Controller_About extends Controller_Template{
    public function action_index()
    {$result = '';
        if(!empty($_POST['name'])){
            $name = Model::factory('index')->insert_names($_POST['name']);;
            $result= $name;
        }
        $this->template->site_name = Kohana::$config->load('common')->get('site_name');
        $this->template->site_description = Kohana::$config->load('common')->get('site_description');
        $this->template->page_title = 'About';
        $this->template->content = View::factory('about/about')->set('result', $result);
        $this->template->styles[] = 'index/index';
    }
}

But this not working, because when I input name, they not puts into database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:56:18+00:00Added an answer on May 26, 2026 at 2:56 am

    Possibly because an empty value was passed to name and the variable doesn’t get initialized unless its non-empty. But it gets used in the following line, outside the if

    $this->template->content = View::factory('about/about')->set('result', $result);
    

    Initialize $result outside the if():

    $result = "";
    if(!empty($_POST['name'])){
        $name = Model::factory('index')->insert_names($_POST['name']);;
        $result= $name;
    }
    

    Or move the entire block that follows the if(){} inside it.

    public function action_index()
    {
        if(!empty($_POST['name'])){
          $name = Model::factory('index')->insert_names($_POST['name']);;
          $result= $name;
    
          // move this inside the if()
          $this->template->site_name = Kohana::$config->load('common')->get('site_name');
          $this->template->site_description = Kohana::$config->load('common')->get('site_description');
          $this->template->page_title = 'About';
          $this->template->content = View::factory('about/about')->set('result', $result);
          $this->template->styles[] = 'index/index';
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that creates other PHP files based on user input.
I created this layout of successive text input fields, 1- Enter data into empty
I have created a C# class file by using a XSD-file as an input.
I have created button 2 below: <input id=Button1 type=button value=Stop onclick=alert('hello world');/> <input id=Button2
I have created a JAR file in this way jar cf jar-file input-files .
I have some data (which users input using WYSIWYG editor). I have created a
I have several scripts that take as input a directory name, and my program
I have created a script that analyzes a set of raw data and converts
I am trying to write a python script to process image files into shapefiles
I've created this script below for a assignment I have. It asks for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.