Welcome Guest, Not a member yet? Register   Sign In
[solved] die() function
#4

[eluser]tuckee[/eluser]
thanks for your reply.

Roy: if i remove die(), it will still run the function "runthis"

initially i thought of doing this
Code:
function check_user()
{
$logged_in_type = $this->session->userdata('type'); //retrieve data from session
if ($logged_in_type == '')
{
  $data['heading'] = 'Sorry!';
  $data['content']="Fail";
  $this->load->view('general_view', $data);
  die();
}
}

function runthis()
{
$this->check_user();
echo 'success';
}


Jason : when u say return do you mean I have to do this?

Code:
function check_user()
{
$logged_in_type = $this->session->userdata('type'); //retrieve data from session
if ($logged_in_type == '')
{
  return false;
}
}

function runthis()
if ($this->check_user())
{
  $data['heading'] = 'login sucess!';
  $data['content']="success";
  $this->load->view('general_view', $data);
}
else
{

  $data['heading'] = 'Sorry!';
  $data['content']="Fail";
  $this->load->view('general_view', $data);
}

i know this will work but there r many function that is needed to check if user has login. if i were to use this way, there are too many copy n paste if else code for each function.
Did i interpret your reply wrongly?


Messages In This Thread
[solved] die() function - by El Forum - 01-19-2012, 03:50 AM
[solved] die() function - by El Forum - 01-19-2012, 03:59 AM
[solved] die() function - by El Forum - 01-19-2012, 04:02 AM
[solved] die() function - by El Forum - 01-19-2012, 04:38 AM
[solved] die() function - by El Forum - 01-19-2012, 05:06 AM
[solved] die() function - by El Forum - 01-19-2012, 07:42 AM
[solved] die() function - by El Forum - 01-19-2012, 12:03 PM
[solved] die() function - by El Forum - 01-19-2012, 04:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB