Help with "Notice: Undefined index: title in" Error

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

mcclints
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Mar 26, 2014 6:40 am

Help with "Notice: Undefined index: title in" Error

Postby mcclints » Wed Mar 26, 2014 6:46 am

Newbie here, why does:

<?php
if(file_exists('content_'.$_GET['title'].'.php')) include 'content_'.$_GET['title'].'.php';
else include 'content_home.php';
?>

Result in:
Notice: Undefined index: title in

Any help is much appreciated :)

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: Help with "Notice: Undefined index: title in" Error

Postby seandisanti » Sat Mar 29, 2014 12:59 am

You're assuming there's a 'title' element present in the $_GET array. Also you don't want to do what you're trying to do if that page is going to be visible to anyone but yourself. all someone would have to do is pass a filename through the address bar and they could force your script to process or display files you really don't want them to be able to see.


Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest