Jump to content

refreshing just part of my index page


gibbo1715

Recommended Posts

All

 

i have an index page that calls a number of includes as follows

 

<HTML>
<?
//**********************************************************************


    
  // Here the header file as directed by the my.inc.php file
    include ($header);
    
//**********************************************************************
    
  // Here the body file as directed by the my.inc.php file

    include ($body);
    
//**********************************************************************
    
  // Here the footer file as directed by the my.inc.php file
    include ($footer);
    
//**********************************************************************

?>
</font>
</body>
</HTML>

 

 

in my $body file i have links to my database and an add delete etc buttons but when i click these they open a whole new web page, is there an easy way of just updating the $body area of my index page when i want the content of this part changed?

 

I was wondering if something like the following would work in my my.inc.php file but this doesnt work for me, any ideas please

 


//Check to see if being redirected from the index page to itself e.g. index.php?body=./inc/body.inc.php
    if ($_POST['body']=="")
    $body = "./inc/body2.inc.php";
    else
//goto this file if just index.php
  $body= $_POST['body'];
    

    
//**********************************************************************

?>
code]



thanks

gibbo

Link to comment
Share on other sites

ok, the first part is i need a get instead of post (opps) but still doesnt work for me  :shrug:

 

Do you literally mean modify the page after output? This is not possible unless you use something such as AJAX, which could fairly easily do what you wish to do.

Link to comment
Share on other sites

Hi

 

Okay, first off, I would suggest using a php framework.  That will make your life much easier.  Google "PHP MVC Frameworks".  Read up on it as much as possible.  With a framework you basically can divide your website into sections and load them independantly and update content accordingly.

 

To answer your question, you can make it work the way you want, although just because you can do it that way, doesn't mean you should and that it is the right way, because it is not.  Using a framework would be the right way.

 

This part of your code:

//Check to see if being redirected from the index page to itself e.g. index.php?body=./inc/body.inc.php

 

If that is the url that you pass to change the body content, it won't work because you have '/' in your url.  A '/' gets interpreted in the url as part of it.  You need to urlencode it.

 

Check out:

http://php.net/manual/en/function.urlencode.php

 

This part:

 if ($_POST['body']=="")

 

Is also wrong.  If the 'body' you are referring to is the part sent through the url, then you need to use $_GET instead of $_POST.

But just remember to urldecode your $_GET value before using it.

 

 

Link to comment
Share on other sites

Thanks

 

got it working although clearly not the right way to go :)

 

Is codeigniter a good framework to use then, im assuming i just upload the libraries with my site and call them?

 

I will do some reading now, just thought id ask the basic question first

 

thanks again

 

gibbo

Link to comment
Share on other sites

PHP frameworks are like car brands.  The answer will depend on who you ask. I'm a huge codeigniter fan.  Although I must admit that some frameworks are better than othere and you will have to research what framework will be best suited to your needs.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.