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

  • SEARCH
  • Home
  • 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 4580036
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:43:36+00:00 2026-05-21T20:43:36+00:00

I have got a very strange input issue in which it seems that my

  • 0

I have got a very strange input issue in which it seems that my seo description box and main content box are linked due to if I input any data into the seo input box it changes in the database in the content area as well but not the otherway around.

View:

<?php
//Setting form attributes
$formpageEdit = array('id' => 'pageEdit', 'name' => 'pageEdit');
$formInputTitle = array('id' => 'title', 'name' => 'title');
$formSEODescription = array('id' =>'seoDescription', 'name' => 'seoDescription');
$formTextareaContent = array('id' => 'textContent', 'name' => 'textContent');
?>

<?php print_r($page);?>

<div id ="formLayout" class="editPage">
<?php echo form_open('admin/editpage/index/'.$page[0]['id'].'/'.url_title($page[0]['name'],'dash', TRUE),$formpageEdit); ?>
<?php echo form_fieldset(); ?>
<h4>You are editing: <?= $page[0]['name']; ?> </h4>
<section id = "validation"><?php echo validation_errors();?></section>
<?php
if($success == TRUE) {
echo '<section id = "validation">Page Updated</section>';   
}
?>
<label><?php echo form_label ('SEO Description:', 'description');?><span class="small">Required Field</span></label>
<?php echo form_input($formSEODescription, $page[0]['description']); ?>
<label><?php echo form_label ('Content:', 'content');?><span class="small">Required Field</span></label>
<?php echo form_textarea($formTextareaContent, $page[0]['content']); ?>
<script type="text/javascript">CKEDITOR.replace('textContent');</script>
<?php echo form_submit('submit','Submit'); ?>
<?php echo form_fieldset_close();
      echo form_close(); ?>
</div>

Model

<?php
/**
* This model handles the sql for the checking of the username in the database
*/
class Page_model extends CI_Model
{

    function __construct()
    {
    parent::__construct();
    }

    function Page_model(){
        parent::Model();
    }

    function getCMSContent($id = NULL) {
        $this->db->where('id', $id);
        $query = $this->db->get('pages', 1);

        if($query->num_rows() > 0) {
            $row = $query->result_array();
            return $row;
        }else{
            return FALSE;
        }
    }

    function updatePage($id = NULL, $data = NULL){
        #set the $data passed to the function into an array, content being the column name.
        $data = array('content' => $data, 'description' => $data);

        $this ->db->where('id',$id);
        $this->db->update('pages', $data);

        return TRUE;
    }
}


?>

Controller

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Editpage extends CI_Controller {

    function __construct(){
    parent::__construct();
    }

  function index($id){

        if(!$this->session->userdata('logged_in'))redirect('admin/home');

        if ($this->input->post('submit')){

            #The User has submitted updates, lets begin!

            #Set The validation Rules   
            $this->form_validation->set_rules('textContent', 'Content', 'trim|required|xss_clean');
            $this->form_validation->set_rules('seoDescription', 'SEO Description', 'trim|required|xss_clean');

            #if the form_validation rules fail then load the login page with the errors. Otherwise continue validating the user/pass
            if ($this->form_validation->run() == FALSE){

                $data['cms_pages'] = $this->navigation_model->getCMSPages($id);
                #connect to getCMSCotent and set the page info equal to the $data['page'] where the row is equal to the passed $id from the URL.
                $data['page'] = $this->page_model->getCMSContent($id);
                $data['sales_pages'] = $this->sales_model->getSalesPages();

                $data['content'] = $this->load->view('admin/editpage', $data, TRUE);
                $this->load->view('admintemplate', $data);

            }               
            #Form Validation passed, so lets continue updating.
                #lets set some variables.
                $content = $this->input->post('textContent', TRUE);
                $content = $this->input->post('seoDescription', TRUE);
                $this->db->escape($content);
                #Now if updatePage fails to update hte database then show "there was a problem", you could echo the db error itself
                if($this->page_model->updatePage($id, $content)) {
                    $data['cms_pages'] = $this->navigation_model->getCMSPages($id);
                    #connect to getCMSContent and set the page info equal to the $data['page'] where the row is equal to the passed $id from the URL.
                    $data['page'] = $this->page_model->getCMSContent($id);
                    $data['success'] = TRUE;
                    $data['content'] = $this->load->view('admin/editpage', $data, TRUE);
                    $this->load->view('admintemplate', $data);
                }//END if updatePage
            }else{
            $data['cms_pages'] = $this->navigation_model->getCMSPages($id);
            $data['sales_pages'] = $this->sales_model->getSalesPages();
            #connect to getCMSCotent and set the page info equal to the $data['page'] where the row is equal to the passed $id from the URL.
            $data['page'] = $this->page_model->getCMSContent($id);
            $data['content'] = $this->load->view('admin/editpage', $data, TRUE);
            $this->load->view('admintemplate', $data);
        }//END if post submitted
    } //END function index()

}
  • 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-21T20:43:37+00:00Added an answer on May 21, 2026 at 8:43 pm

    Found it:

      $content = $this->input->post('textContent', TRUE);
      $content = $this->input->post('seoDescription', TRUE);
    

    [update below]

    You are overwriting the $content variable with the content of seoDescription so textContent never reaches your db.

    You need to update your updatePage function:

    function updatePage($id = NULL, $content = NULL, $description = NULL){
        #set the $data passed to the function into an array, content being the column name.
        $data = array('content' => $content, 'description' => $description);
    
        $this ->db->where('id',$id);
        $this->db->update('pages', $data);
    
        return TRUE;
    }
    

    and call it appropriately:

    [...]
        #Form Validation passed, so lets continue updating.
            #lets set some variables.
            $content     = $this->input->post('textContent', TRUE);
            $description = $this->input->post('seoDescription', TRUE);
            $this->db->escape($content);
            $this->db->escape($description);
            #Now if updatePage fails to update hte database then show "there was a problem", you could echo the db error itself
            if($this->page_model->updatePage($id, $content, $description)) {
    [...]
    

    By the way are you sure you are using db->escape correctly? The way you’re calling it will only work if the escape function accepts parameters by reference (e.g. using & in front of the parameter name, and setting this value to the escaped value). I’d expect this code to be the correct version, but I don’t know your db class so I may be wrong:

            $content     = $this->db->escape($this->input->post('textContent', TRUE));
            $description = $this->db->escape($this->input->post('seoDescription', TRUE));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got very strange problem. I have one php website which is running in
This is very strange. I've got a simple form. I have a file input
I have done some tests with QueryPerformanceCounter and got strange results. It seems that
I have got a very, very strange problem in my C++ OpenGL application. I
I have got problem with django's UserCreationForm. It's very strange because ween I: view:
a noob question here. I have a very strange situation that's very puzzling to
Ok so this is kind of a strange issue, but I have got two
Well friends, I have got this query which works but is very long for
We have got loads of options for php + MySQL + Apache combo... Which
I have got a python script which is creating an ODBC connection. The ODBC

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.