How to Blog Website in Codeigniter and Create Blog post page ko kese likhe codeigniter php main. Codeigniter Input fields php simple Codeing kese kare
<?php echo br(3);
if( ! $this->session->userdata('email')){
redirect('My_controller/login');
}
?>
<div class="container">
<div class="row">
<div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
<div class="card" style="margin-top: 15px; ">
<h3 class="text-center"> ADD POST YOUR ARTICLE FOR SEO </h3>
<form method="post" enctype="multipart/form-data" accept-charset="utf-8" action="">
<input type="text" name="title" class="inputform form-control" placeholder="POST YOUR TITLE BLOG OR YOUTUBE OR FACEBOOK............" style="height: 70px" > </br>
<?php echo form_error('title','<div style="color:red">', '</div>'); ?>
<div class="row">
<div class="col-4">
<input type="text" name="blog_parmalink" placeholder="TYPE HERE PARMALINK SHORT TITLE" class="inputform form-control">
<?php echo form_error('blog_parmalink','<div style="color:red">', '</div>'); ?>
</div>
<div class="col-4">
<input type="text" name="blogname" class="inputform form-control"placeholder="ENTER YOUR BLOG NAME, OR YOUTUBE CHANNAL NAME ........" >
<?php echo form_error('blogname','<div style="color:red">', '</div>'); ?>
</div>
<div class="col-4">
<input type="text" name="website" class="inputform form-control" placeholder="TYPE HERE BLOG OR WEBSITE LINK">
<?php echo form_error('website','<div style="color:red">', '</div>'); ?>
</div>
</div> </br>
<!-- // ----------------------------------------------------------------------------------------------------- -->
<div class="row">
<div class="col-6">
<input type="text" name="youtube_link" class="inputform form-control"placeholder="ENTER HERE YOUTUBE CHANNAL LINK ........" >
<?php echo form_error('youtube_link','<div style="color:red">', '</div>'); ?>
</div>
<div class="col-6">
<input type="text" name="facebook_link" class="inputform form-control" placeholder="TYPE HERE FACEBOOK PAGE LINK .......">
<?php echo form_error('facebook_link','<div style="color:red">', '</div>'); ?>
</div>
</div> </br>
<!-- /////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<div class="row">
<div class="col-4">
<input type="text" name="country" class="inputform form-control" placeholder="TYPE HERE COUNTRY">
<?php echo form_error('country','<div style="color:red">', '</div>'); ?>
</div>
<div class="col-4">
<input type="text" name="state" class="inputform form-control" placeholder="TYPE HERE STATE">
<?php echo form_error('state','<div style="color:red">', '</div>'); ?>
</div>
<div class="col-4">
<input type="text" name="city" class="inputform form-control" placeholder="TYPE HERE CITY">
<?php echo form_error('city','<div style="color:red">', '</div>'); ?>
</div>
</div> </br>
<select name="email" id="email" class="inputform form-control">
<option value="<?php echo $this->session->userdata('email'); ?>"> <?php echo $this->session->userdata('email'); ?> </option>
</select> </br>
<input type="file" name="img_Src3" alt="img_alt" class="inputform form-control" >
<h6> pls. Image Same Size Upload </h6> </br>
<div class="row">
<div class="col-6">
<input type="text" placeholder="img_alt" name="img_alt" class="inputform form-control"> </br>
</div>
<div class="col-6">
<input type="text" placeholder="IMAGE ADD_CAPTION" name="add_caption3" class="inputform form-control"> </br>
</div>
</div>
<textarea type="text" name="content" class="inputform form-control ckeditor"> </textarea>
<?php echo form_error('content','<div style="color:red">', '</div>'); ?>
<div class="form-group">
<input type="submit" class="submit btn btn-success btn-lg btn-block" value="ADD POST YOUR ARTICLE FOR SEO">
</div>
</form>
</div>
</div>
</div>
</div>
/* -----------------------------------------------------------------------
End product concatination start
----------------------------------------------------------------------*/
public function blogpage_add() {
// $this->data['data'] = $this->User_model->myaccount($_SESSION['email']);
$this->load->view('inc/header');
$this->load->view('inc/nav');
$this->load->view('blog/blogadd_page');
$this->load->view('inc/footer');
}
public function post_article() {
$this->form_validation->set_rules('title','title','trim|required');
$this->form_validation->set_rules('blogname','blogname','trim|required');
$this->form_validation->set_rules('website','website','trim|required');
$this->form_validation->set_rules('country','country','trim|required');
$this->form_validation->set_rules('state','state','trim|required');
$this->form_validation->set_rules('city','city','trim|required');
// $this->form_validation->set_rules('img_Src3','img_Src3','trim|required');
//$this->form_validation->set_rules('add_caption3','add_caption3','trim|required');
$this->form_validation->set_rules('content','content','trim|required');
if($this->form_validation->run()) {
$blog_parmalink =$this->generate_url_slug_product($this->input->post('blog_parmalink'),'blog_table');
$title = $this->input->post('title');
// $blog_parmalink = $this->input->post('blog_parmalink');
$email = $this->input->post('email');
$blogname = $this->input->post('blogname');
$website = $this->input->post('website');
$youtube = $this->input->post('youtube_link');
$facebook = $this->input->post('facebook_link');
$country = $this->input->post('country');
$state = $this->input->post('state');
$city = $this->input->post('city');
$content = $this->input->post('content');
$add_caption3 = $this->input->post('add_caption3');
$img_alt = $this->input->post('img_alt');
$file = "";
// ---------------Start Image Upload Code ---------------------------//
$config['upload_path'] = './assets/uploads/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('img_Src3')) {
$error = array('error' => $this->upload->display_errors());
} else {
$data = array('upload_data' => $this->upload->data());
$file = $data['upload_data']['file_name'];
}
// --------------- Image Upload Code end ---------------------------//
$insert_user = array(
'blog_title' => $title,
'blog_parmalink' => $blog_parmalink,
'email' => $email,
'blog_name' => $blogname,
'blog_url' => $website,
'youtube_link' => $youtube,
'facebook_link' => $facebook,
'country' => $country,
'state' => $state,
'city' => $city,
'blog_description' => $content,
'add_caption3' => $add_caption3,
'img_alt' => $img_alt,
'img_src3' => $file,
'created_date' => date('y/m/d')
);
$insert_id = $this->User_model->add_user_post($insert_user);
// echo '<pre>';
// echo print_r($insert_users);
// echo '</pre>';
redirect(base_url().'My_controller/blog_concate');
} else {
$this->load->view('inc/header');
$this->load->view('inc/nav');
$this->load->view('blog/add_post');
$this->load->view('inc/footer');
}
}
/* ----------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------*/
function generate_url_slug_product($string,$table,$field='blog_parmalink',$key=NULL,$value=NULL){
$t =& get_instance();
$blog_parmalink = url_title($string);
$slug = strtolower($blog_parmalink);
$i = 0;
$params = array ();
$params[$field] = $blog_parmalink;
if($key)$params["$key !="] = $value;
while ($t->db->where($params)->get($table)->num_rows())
{
if (!preg_match ('/-{1}[0-9]+$/', $blog_parmalink ))
$blog_parmalink .= '-' . ++$i;
else
$blog_parmalink = preg_replace ('/[0-9]+$/', ++$i, $slug );
$params [$field] = $blog_parmalink;
}
return $blog_parmalink;
}
/*--------------------------------------------------------------------------------------------------------*/
/* -----------------------------------------------------------------------
Blog Concate view page function
----------------------------------------------------------------------*/