I am making my first dynamic site and have an error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • danny causer
    New Member
    • Jan 2011
    • 1

    I am making my first dynamic site and have an error

    Hi, I am trying to make my first dynamic site using php. I am however getting the following error message on my first page:
    _______________ _______________ _______________ __________
    My first Page
    home
    tutorials

    Notice: Undefined index: page in C:\wamp\www\tes t\index.php on line 18
    welcome to my website
    _______________ _______________ _______________ _________

    my tutorial link works and doesnt display the error. but my index page makes this come up. my code is as follows
    _______________ _______________ _______________ __________
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>My First Page</title>
    </head>
    
    <body>
    
    <h1>My first Page</h1>
    
    <a href="index.php">home</a><br />
    <a href="index.php?page=tutorials">tutorials</a><br />
    
    
    
    <?php
     $page = $_GET['page'];
    	
    	if ($page)
    	
    	{
    		include ("content/".$page.".php");
    		
    		}
    		else
    		{
    			
    			echo "welcome to my website";
    			}
    		
    		
    ?>
    
    </body>
    </html>
    _______________ _______________ _______________ _________

    Please help if you can, Im using wamp and firefox!
    Last edited by danny causer; Jan 12 '11, 09:03 PM. Reason: forgot to put something
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    If you click on this link
    Code:
    <a href="index.php">home</a><br />
    You will get the error becuase this line
    Code:
    $page = $_GET['page'];
    Is looking for something that doesn't exist.
    Use isset()

    Comment

    Working...