Fatal error: Call to undefined function get_header()
I can't get this working. I am using twentythirteen default theme shipped with wordpress. I have created a custom template called table.php
and I also used <?php template name ?>
. This custom template simply shows up all records in a database. Its working just fine but header and footer are missing and when I try to add header and footer of the current theme by adding get_header
and get_footer
, it throws a fatal error. Here is the code:
Just to mention, I used index.php
that is inside twentythirteen folder, not from root folder where wp-config
file or any other index.php
for that matter.
<?php
/**
* The main template file
*
* This is the most generic template file in a WordPress theme and one of the
* two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* For example, it puts together the home page when no home.php file exists.
*
* @link http://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Thirteen
* @since Twenty Thirteen 1.0
*/
get_header(); ?>
<DIV class="form">
<form method = "post" action="<?php echo get_stylesheet_directory_uri(); ?>/dbentry.php">
First Name: <input type="text" name = "first">*<?php echo $first_error;?><br>
Last Name: <input type="text" name = "last">*<?php echo $last_error; ?><br>
Email:         <input type="text" name = "email"><br>
Telephone: <input type="number" name = "telephone">*<?php echo $tele_error; ?><br>
Gender:   
<input type="radio" name = "gender" value = "female">Female
<input type="radio" name = "gender" value = "male">Male
<br>
<input type="submit" value ="submit" name="submit"><br>
</form>
</DIV>
<form action="<?php echo get_stylesheet_directory_uri(); ?>/tab.php" method="post">
<input type="submit" name = 'submit2' value = 'http://localhost/wordpress/?page_id=11'>
</form>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Here is the code where the call will go after pressing the "Show all records" button.
<?php
/**
* The template for displaying all pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages and that other
* 'pages' on your WordPress site will use a different template.
*
* @package WordPress
* @subpackage Twenty_Thirteen
* @since Twenty Thirteen 1.0
*/
/*
Template name: tab
*/
get_header(); ?>
<div class="table">
<table class = "border">
<?php
require "db.php";
if(isset($_POST['submit2'])){
$query = "SELECT * FROM person";
$result = mysqli_query($connection, $query);
$row = '';
$id = "";
echo "<tr>";
echo "<th><b>ID</b></th>";
echo "<th><b>FIRST</b></th>";
echo "<th><b>LAST</b></th>";
echo "<th><b>EMAIL</b></th>";
echo "<th><b>TELEPHONE</b></th>";
echo "<th><b>GENDER</b></th>";
echo "<th scope='row'>EDIT</th>";
echo "<th>DELETE</th>";
echo "</tr>";
echo "<tr>this is working just fine</tr>";
while($row = mysqli_fetch_array($result)){
$id = $row['ID'];
echo $id ;
echo "<tr><td>".$row['ID']."</td><td>".$row['First']."</td><td>".$row['Last']."</td><td>".$row['Email']."</td><td>".$row['Telephone'].
"</td><td>".$row['Gender']."</td><td>"."<a href='edit.php?ID=$id'><input type='button' class = 'edit' value = 'Edit'></a>"."</td><td>"."<a href='delete.php?ID=$id'><input type='button' class = 'del' value='Delete'></a>"."</td></tr>";
}
mysqli_close($connection);
}
?>
</table>
</div>
<table>
<tr>jsdnsdjnsjd</tr>
</table>
<form action="form.php" method="post">
<input type="submit" name="new" value="New Entry" class = "new">
</form>
<?php get_sidebar(); ?>
<?php get_footer(); ?>