gibbo1715 Posted December 4, 2009 Share Posted December 4, 2009 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 Quote Link to comment Share on other sites More sharing options...
gibbo1715 Posted December 4, 2009 Author Share Posted December 4, 2009 ok, the first part is i need a get instead of post (opps) but still doesnt work for me Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 4, 2009 Share Posted December 4, 2009 ok, the first part is i need a get instead of post (opps) but still doesnt work for me 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. Quote Link to comment Share on other sites More sharing options...
Tazz Posted December 4, 2009 Share Posted December 4, 2009 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. Quote Link to comment Share on other sites More sharing options...
gibbo1715 Posted December 4, 2009 Author Share Posted December 4, 2009 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 Quote Link to comment Share on other sites More sharing options...
Tazz Posted December 4, 2009 Share Posted December 4, 2009 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. Quote Link to comment Share on other sites More sharing options...
gibbo1715 Posted December 4, 2009 Author Share Posted December 4, 2009 I am just progamming php as a hobby at the mo and dont really have anything i want to build yet, just enjoying learning the language but would like to make sure as I go I learn to do things right thanks Gibbo Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.