Jump to content

debbie-g85

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by debbie-g85

  1. I have managed to get this to work but it seems like it is a very long and messy solution. I was wondering if anyone had an idea of how this can be done better. I am new to php and don't know a lot. It shows the text between the tags <h1> and </h1> from the content of a different file Basically I had to start the substr() from the fourth position so it would actually skip the "<h1>" being included, and because I started on the fourth postion I then had to finish four places back to skip the "</h1>" being included. <?php $id = $_GET['id']; $homepage = file_get_contents("./".$id.".php"); $title = stristr($homepage,"<h1>"); $titlepos = strpos($homepage,"</h1>"); $endpos = $titlepos - 4; echo "Title " . substr($title,4,$endpos); ?>
  2. This might be a very easy problem to solve. I am literally brand new to php. I am trying to create a simple site that will load content depending on what page 'id' is in the URL and if it doesn't exist to show a page for that scenario. eg index.php?id=1 will show the page 1.php It works fine apart from showing an error when there is no id at all, eg www.website.com will show an error but www.website.com/index.php?id=1 will show a page I want to be able to show the homepage if there is no 'id' at all. <?php $id = $_GET['id']; if(file_exists("./".$id.".php")) { include ("./".$id.".php"); } else { include ("404.php"); } ?> Any help is appreciated Thanks
×
×
  • 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.