Welcome Guest, Not a member yet? Register   Sign In
check insert process and redirect
#1

[eluser]Mostafa Hassan[/eluser]
Hi all ...

i have a db insert opertation

Code:
$result=$this->add_student_model->insert('students',$data);

i want to check if operation complete or not ,, and redirect to another form

in smarty template engine .. i use

Code:
if ($result)
{
           $SF->msg('insert complete!!'); // smarty message
           $SF->go_to('form.php',2); // redirect process
}

what is the alternative code in ci ?

i searched the user guide but i ddnt found any thing Sad

thanks Smile
#2

[eluser]tomcode[/eluser]
Code:
if ($result)
{
    $this->load->view('success_view');
}
else $this->load->view('failed_view');

Is that what You mean ?
#3

[eluser]Mostafa Hassan[/eluser]
i tried this code before

but it shows nothing

when the insert operation done .. it's shows nothing (white page) !!

thanks tomcode for reply
#4

[eluser]tomcode[/eluser]
What do You have in Your views ?
#5

[eluser]Mostafa Hassan[/eluser]
no tomcode i have no views but i tried this code .. have no views

Code:
if ($result)
{
    echo"Done";
}
    echo"Error";

i tried just now anew code

Code:
if ($result=TRUE)
{
    echo"Done";
}
    echo"Error";

it works fine !!

now i need your help with redirecting to another page after showing "Done"

and many thanks again
#6

[eluser]tomcode[/eluser]
Code:
// $result = TRUE is wrong, You could do $result == TRUE, but that's the same as :
if ($result)
{
    // echo"Done";

   // load the helper
   $this->load->helper('url');

  // redirect to Your URI
  redirect('your/uri');
}
// You should add else
else echo"Error";
#7

[eluser]Mostafa Hassan[/eluser]
YES !!!

it Works fine ...

sooooo mannnnny thanks my friend TomCode Smile

i just want to ask u for a simple something

in smarty template engine .. when i want to show amessage .. i dont have to make aview

i just call this function

Code:
$SF->msg('my message here'); // smarty message

this function show asimple view with the test "my message here"

what about message function in ci ..
#8

[eluser]tomcode[/eluser]
There is no message function in CI, only error messages show_404() and show_error().

Read the user guide for details.
#9

[eluser]Mostafa Hassan[/eluser]
ok ,, thank you Smile


this comment

Code:
// $result = TRUE is wrong, You could do $result == TRUE, but that's the same as :

Code:
$result == TRUE

that's mean variable result match letters (TRUE)

but

Code:
$result = TRUE

that's mean operation is done successfully

and so many thanks tomcode

hope for u great success Smile




Theme © iAndrew 2016 - Forum software by © MyBB