mikemxc Posted April 15, 2009 Share Posted April 15, 2009 Im sorry to ask im sure such a silly question. But, I can't for the life of me find the simple script to include a page with in one php page. where you would use te url like http://anypage.com/index.php?id=signup then the script would just include signup.php within index.php. help please.. thanks Link to comment https://forums.phpfreaks.com/topic/154254-php-script-to-include-webpages-with-in-a-page/ Share on other sites More sharing options...
Mchl Posted April 15, 2009 Share Posted April 15, 2009 Most basic form include($_GET['id'].".php"); careful, as this can potentially lead to XSS attacks. Link to comment https://forums.phpfreaks.com/topic/154254-php-script-to-include-webpages-with-in-a-page/#findComment-810966 Share on other sites More sharing options...
mikemxc Posted April 15, 2009 Author Share Posted April 15, 2009 Thank you for the reply, i do understand it can be a risk. Is there anything anyone can suggest or would it just be safer not doing this? Link to comment https://forums.phpfreaks.com/topic/154254-php-script-to-include-webpages-with-in-a-page/#findComment-810971 Share on other sites More sharing options...
Mchl Posted April 15, 2009 Share Posted April 15, 2009 for example you can create a list of allowed pages $whitelist = array("signup","about","products"); //only allow pages from this list if(in_array($_GET['id'],$whitelist)) { //check if page to be included is in the list include($_GET['id'].".php"); } else { die("No such page!"); } Link to comment https://forums.phpfreaks.com/topic/154254-php-script-to-include-webpages-with-in-a-page/#findComment-810981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.