致命错误:调用未定义的函数get\\u header()
我不能让它工作。我使用wordpress附带的213个默认主题。我创建了一个名为table.php
我还使用了<?php template name ?>
. 这个自定义模板只显示数据库中的所有记录。它工作正常,但缺少页眉和页脚,当我试图通过添加get_header
和get_footer
, 它抛出一个致命错误。代码如下:
我要说的是,我曾经index.php
它位于Twenty13文件夹中,而不是根文件夹中wp-config
文件或任何其他index.php
就这点而言。
<?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(); ?>