alf Posted December 21, 2008 Share Posted December 21, 2008 I've created a form that updates my database. Upon submitting the new data you're given confirmation via an echo that appears within a new page... The new page is plain and unstyled. Just wondered how you go about updating content within a page template (eg, the title, background, navigation menu, etc all stay the same but only part of the page changes to give an echo'd confirmation) PS. Sorry for the newbie PHP quetion but I'm still learning Link to comment https://forums.phpfreaks.com/topic/137938-echo-within-page-without-opening-new-unstyled-page-newbie-question/ Share on other sites More sharing options...
MasterACE14 Posted December 22, 2008 Share Posted December 22, 2008 you can create your layout, then break it into different pages. Like header.inc.php , leftpanel.inc.php , footer.inc.php and Then you have your template setup like... <?php include("header.inc.php"); include("left.inc.php"); // page content goes here $page = $_GET['page']; if(file_exists(isset($page))) { include($page); } else { include("homepage.php"); } include("footer.inc.php"); ?> That's really basic, but that's a start for you. Regards ACE Link to comment https://forums.phpfreaks.com/topic/137938-echo-within-page-without-opening-new-unstyled-page-newbie-question/#findComment-721070 Share on other sites More sharing options...
alf Posted December 22, 2008 Author Share Posted December 22, 2008 cool, so I understand including external pages to create the page, but the $page funtion really confuses me... That's just saying "if there's information in the address bar sent from a form, then include that"... right? So, if for example I've made a page made up of four files: 1) header.php (stays the same on each page) 2) input.php (the form that updates my database) 3) confirmation.php (text that says "record updated") 4) index.php (template file) I open index.php and update a database file, when I submit I'd like the input.php to change to confirmation.php while the remaining content remain the same, however currently I'm stuck with confirmation.php loading as en entirely new page! I'm so confused... where am I going wrong?! Link to comment https://forums.phpfreaks.com/topic/137938-echo-within-page-without-opening-new-unstyled-page-newbie-question/#findComment-721298 Share on other sites More sharing options...
mattjones Posted December 22, 2008 Share Posted December 22, 2008 You could make the form action submit to the same page the form is on and deal with the form processing on that page. if (!$_POST['submit']) { //form here } else { //form prosessing and successful update statement here. } Link to comment https://forums.phpfreaks.com/topic/137938-echo-within-page-without-opening-new-unstyled-page-newbie-question/#findComment-721317 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.