-2

I'll get the error

Notice: Undefined index: page in C:\xampp\htdocs\ajaxx\load_page.php on line 3

This is my full code:

<?php

if(!$_POST['page']) die("0");

$page = $_POST['page'];

if(file_exists('pages/page_'.$page.'.html'))
echo file_get_contents('pages/page_'.$page.'.html');

else echo 'There is no such page!';
?>

It was working yesterday but all of a sudden it gives me this error. The full code is downloaded from A simple AJAX website with jQuery

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
bemyhero
  • 63
  • 6
  • @JayBlanchard I've had a look on that page before but it doesn't help me any further. – bemyhero Dec 16 '15 at 13:25
  • Without your form markup I can only guess that you must not be sending an input named 'page' in your form post. – Jay Blanchard Dec 16 '15 at 13:27
  • @JayBlanchard The found markup can be found by clicking the link in the post. There's a demo to be found there. – bemyhero Dec 16 '15 at 13:28
  • 2
    Please post your code here so it is preserved for future SO visitors. Folks here are not likely to travel to a link to wade through code that isn't yours. – Jay Blanchard Dec 16 '15 at 13:29

1 Answers1

0

$_POST['page'] does not exits.

In my experience the $_POST value is always set so doing isset("..") ensures ['page'] is sent. I think 'page' is not been posted. It may be good to do a print_r($_POST) and see what is posted.

if( isset($_POST['Page']) )
{

  $page = $_POST['page'];

  if(file_exists('pages/page_'.$page.'.html'))
  echo file_get_contents('pages/page_'.$page.'.html');

  else echo 'There is no such page!';
}
else
echo "Value not posted";
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
Richard perris
  • 511
  • 1
  • 6
  • 15