0

I have a page called admin.php. It has 2 buttons on the left, one view records and another creates a record. When the buttons are clicked it loads up the content into a div on the right. It works OK with the view records button, but when I click the create record it loads up behind the view records content.

A bit hard to describe so I have created two PhpFiddle pages to demonstrate.

Here is the admin page: http://phpfiddle.org/main/code/9vgr-dn34

Here is the create record page: http://phpfiddle.org/main/code/bvan-3wph

llanato
  • 2,508
  • 6
  • 37
  • 59
Jordan
  • 97
  • 11

2 Answers2

0

Instead of using a form to submit the users actions you should use a GET variable.

The link could be:

<a href="admin/?page=PAGE1">Get Page 1 Content</a>

You can then grab the variable by using this code

<?php
if(isset($_GET['page'])) {
   if($_GET['page'] == "PAGE1") { // It's page one so load that page
      include('includes/page1.php');
   } else {
      // Load the other pages
   }
} else {
   // No page selected: Load the default page
   include('includes/default.php');
}

Edit: Even better still add multiple pages and include the header and footer.

Eamon Boyle
  • 81
  • 2
  • 8
0

if createRecord is clicked then run admin-create.php

if(isset($_POST['createRecord'])) {
include ('admin-create.php');

without the next line the admin-create content will be loaded behind the view-records content

exit;
}
Jordan
  • 97
  • 11