Jump to content

echo within page (without opening new unstyled page)... Newbie Question


alf

Recommended Posts

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 :)

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

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?!

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.
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.