CodeIgniter Forums
refresh the page after clicking the button - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: refresh the page after clicking the button (/showthread.php?tid=21582)

Pages: 1 2


refresh the page after clicking the button - El Forum - 08-14-2009

[eluser]mrcoder[/eluser]
Hi

I am new to CI.I am facing a problem in my application.

I have a view page which is having 4 image uploads, at the bottom iam having preview, submit buttons.iam calling the preview function while clicking the preview page.after clicking the preview button iam getting the preview page and the uploaded images are not reflecting untill iam refreshing the browser.is there any way to get the refreshed page after clicking the preview button .

Thanks in advance


refresh the page after clicking the button - El Forum - 08-14-2009

[eluser]InsiteFX[/eluser]
Hi,



Code:
$this->load->helper('url');

redirect('/your form/', 'refresh');

Hope this helps.

Enjoy
InsiteFX


refresh the page after clicking the button - El Forum - 08-16-2009

[eluser]mrcoder[/eluser]
Hi,

But i dont wanna redirect the page.but iam using

$this->load->view('loginsuccess', $data);

can i use the above as
$this->load->view('loginsuccess', $data,'refresh');


refresh the page after clicking the button - El Forum - 08-16-2009

[eluser]Yorick Peterse[/eluser]
Redirecting to the same page does what you want, there is no other php based solution other than this one.


refresh the page after clicking the button - El Forum - 08-17-2009

[eluser]mrcoder[/eluser]
no i wanna forward the view page.like
$this->load->view(‘loginsuccess’, $data);
at the same time i wanna refresh my page


refresh the page after clicking the button - El Forum - 08-17-2009

[eluser]InsiteFX[/eluser]
As I and Yorick Peterse stated to you use the above redirect on the page you want to refresh use that code and redirect to the page!

Enjoy
InsiteFX


refresh the page after clicking the button - El Forum - 08-17-2009

[eluser]mrcoder[/eluser]
in redirect can i cal the view directly with out passing it to controler.

redirect('loginsuccess', 'refresh');

where loginsuccess page is the view page


refresh the page after clicking the button - El Forum - 08-17-2009

[eluser]Dam1an[/eluser]
No, a redirect triggers a new HTTP request, so you start of at the controller level again


refresh the page after clicking the button - El Forum - 08-17-2009

[eluser]mrcoder[/eluser]
my function is


function saveminiprofile() {
$this->load->helper(array('form', 'url'));
$data['title'] = "Welcome to OneLine";
$data['headline'] = "Mini Profile";
$data['header'] = 'afterloginheader';
$data['menu'] = 'menu';
$data['fotter'] = "<p>Copyright © 2008 itdots.com. All rights reserved.</a>.</p>";
$data['include'] = 'home';
$this->load->vars($data);
$firstname = $this->input->xss_clean($this->input->post('firstname'));

$lastname = $this->input->xss_clean($this->input->post('lastname'));
$email = $this->input->xss_clean($this->input->post('email'));
$username = $this->session->userdata('username');
$password = $this->input->xss_clean($this->input->post('password'));
$country = $this->input->xss_clean($this->input->post('country'));
$mojo = $this->input->xss_clean($this->input->post('mojo'));
$phone1 = $this->input->xss_clean($this->input->post('phone1'));
$phone2 = $this->input->xss_clean($this->input->post('phone2'));
$specialities = $this->input->xss_clean($this->input->post('specialities'));
$config['upload_path'] = 'assets/uploads';
$config['allowed_types'] = 'gif|jpg|png';

$this->load->model('login_model', '', True);
$data['user_details'] = $this->login_model->getuserdetails($username);
$data['specialities_details'] = $this->login_model->getspecialitiesdetails($username);
$data['photos_url'] = $this->login_model->getphotodetails($username);
$data['photo_id'] = $this->login_model->getphotoid($username);
//$config['max_size'] = '600';
//$config['max_width'] = '1024';
//$config['max_height'] = '768';
// loading the upload class
$this->load->library('upload', $config);
$file_name_arr = array('photo1', 'photo2', 'photo3','photo4');
//$file_name_arr=array('userfile1');

for ($i = 0; $i < 4; $i++) {

if($_FILES[$file_name_arr[$i]]['name'] != '')
{
$id = $this->input->xss_clean($this->input->post("h".$file_name_arr[$i]));
if (!$this->upload->do_upload($file_name_arr[$i])) {
$error = array('error'=>$this->upload->display_errors());

} else {

$data1 = array('upload_data'=>$this->upload->data());
//$this->load->view('upload_success', $data);
$filename = $data1['upload_data']['file_name'];
if($filename=='')
$target1 = '../../assets/uploads/nopicture.jpg';
else
$target1 = '../../assets/uploads/'.$filename;

$this->load->model('login_model', '', True);
$res = $this->login_model->savephotos($target1, $username,$id);
}
}
}
$this->load->model('login_model', '', True);
$res = $this->login_model->saveminiprofile($firstname, $lastname, $email, $username, $password, $country, $mojo, $phone1, $phone2, $specialities);
$data['message'] = "mini pofile crated successfully";
$this->load->view('loginsuccess', $data,'refresh');


}

if i use redirect("loginsuccess','refresh')
again i have to pass it to another controler.in controler i have to get agian all the values which are set in loginsuccess paqge.


refresh the page after clicking the button - El Forum - 08-17-2009

[eluser]Yorick Peterse[/eluser]
[quote author="mrcoder" date="1250508668"]no i wanna forward the view page.like
$this->load->view(‘loginsuccess’, $data);
at the same time i wanna refresh my page[/quote]

You can not refreh a page and redirect it at the same time. If you want the same page to be updated after submitting the form, use the following :

Code:
&lt;?php
If($_POST)
{
    // update page
}
?&gt;