Hello,
I am new to PHP and I would like to do the following: In my website, the user can add a blog but I would like the blog to go to admin first before it gets published ( The admin has the authority to publish or un-publish a blog).
At the moment, the blog appears on the website and in the admin view it shows that it has not been published yet.
this is my code now:
<pre lang="PHP">
header("Location: http://www.arabrecycling.org/user/blogger/");
</pre>
I would like it to do something like //redirect('admin/addBlogs',$data) but still refresh the page. Is that possible?
How Do I Send Data To The Admin And Refresh The Page
Moderator: General Moderators
Re: How Do I Send Data To The Admin And Refresh The Page
Given that you've described nothing about this blogging thing you have or how it works, "probably".
Re: How Do I Send Data To The Admin And Refresh The Page
oh sorry. The blog form is a normal form that redirects to this controller..
Code: Select all
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
**/
class blogsFin extends CI_Controller {
function _blogsFin()
{
parent::controller();
$this->config->load('constants.php');
}
public function index()
{
$date = date('Y-m-d');
$tagid = uniqid();
$retrieve = $this->session->all_userdata();
$author = 'UNESCO Qatar';
$config['file_name'] = uniqid();
$config['upload_path'] = UP_PATH;
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('userfile1'))
{
$error = $this->upload->display_errors();
$category = url_title($this->input->post('category'),'dash', TRUE);
$data = array(
'title'=>$this->input->post('name'),
'category'=>$category,
'country'=>$this->input->post('country'),
'author'=>$author,
'content'=>$this->input->post('wysiwyg'),
'tagid'=>$tagid,
'date'=>$date,
'userid'=>$retrieve['uid'],
'status'=>0
);
$this->session->set_flashdata('message', ADD_MSG.$error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$filepath = $data['upload_data']['file_name'];
$config['image_library'] = 'gd2';
$config['source_image'] = UP_PATH.$filepath;
$config['new_image'] = UP_PATH.'thumbs/';
$config['create_thumb'] = TRUE;
$config['thumb_marker'] = '';
$config['maintain_ratio'] = TRUE;
$config['width'] = 125;
$config['height'] = 120;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$category = url_title($this->input->post('category'),'dash', TRUE);
$data = array(
'title'=>$this->input->post('name'),
'category'=>$category,
'country'=>$this->input->post('country'),
'author'=>$author,
'content'=>$this->input->post('wysiwyg'),
'image'=>$filepath,
'tagid'=>$tagid,
'date'=>$date,
'userid'=>$retrieve['uid'],
'status'=>0
);
//$this->session->set_flashdata('message', ADD_MSG);
}
$this->db->insert(TBL_BLG,$data);
if($this->input->post('tag'))
{
$this->load->library('Common');
$this->common = new common();
if($this->common->validate($this->input->post('tag')))
{
$tag = explode(',',$this->input->post('tag'));
foreach($tag as $value)
{
if($this->articles_model->post_exists($value,TBL_ART_TG,'tag'))
{
$count = $this->articles_model->get_by_tag($value);
$newCount = $count->count + 1;
$data = array('count' => $newCount);
$this->db->where('tag', $value);
$this->db->update(TBL_BLG_TG, $data);
}
else
{
$data = array('count' => 1,'tag' => $value,'tagid' => $tagid);
$this->db->insert(TBL_BLG_TG, $data);
}
}
}
else
{
$tagError = '<br />Invalid tags';
}
}
//$this->session->set_flashdata('message', 'Invalid Tag');
$data['pageTitle'] = PAGE_TITLE;
//redirect('admin/addBlogs',$data);
header("Location: http://www.arabrecycling.org/user/blogger/");
//redirect($_SERVER['PHP_SELF']);
}
}
/* End of file admin.php */
/* Location: ./application/controllers/admin.php */