View Full Version : i wanna learn PHP
Goukhan
December 29th, 2004, 19:24
alright
i wanna learn how to make a site using PHP, so the links would be set up are: http://site.com/main.php?page=page.html (or somethin like that)
i know how to do php include script, but thats about it
i only have Macromedia Dreamweaver MX 2004
if u can help plz msn me at punjabandthefurious@hotmail.com
ozwebworld
December 30th, 2004, 01:13
Hi,
Just put this code in main.php where you want the page included when the link (http://site.com/main.php?page=page.html) is clicked.
<?
if ($_GET['page']) {
// add any action you want performed
include "$_GET[page]";
}
?>
For the above to work, page.html must be in the same directory, unless the filepath is included in $_GET[page]
(i.e ?page=/filepath/to/page.html)
link92
December 30th, 2004, 07:46
That has huge security wholes, a better way to do that is:
<?PHP
if (file_exists($_GET['page'])) {
// The file exists, so include...
include $_GET
} else {
// File doesn't exist, so output file does not exist...
echo 'File does not exist;
}
?>
Goukhan
December 30th, 2004, 12:28
sorry guys, but this isn't making much sense to me, i tried both but can't get them to work :S
if any of u have MSN can u add me to MSN? punjabandthefurious@hotmail.com
thnx
Decker
December 30th, 2004, 14:04
I've put a couple of links to some helpfull online tutorials that may help.
http://uk2.php.net/tut.php
http://www.w3schools.com/php/default.asp
http://www.gimpster.com/wiki/PhpTutorial
http://www.rci.rutgers.edu/~jfulton/php1/
http://www.freewebmasterhelp.com/tutorials/php
Goukhan
December 30th, 2004, 16:25
thanks decker, i'll giv 'em a looksee
Decker
December 30th, 2004, 16:37
No probs, good starter info :)
x8r
January 1st, 2005, 03:29
I've always liked buying books when I wanted to learn something. Try going to Barnes and Noble and finding books on PHP. They have some books on PHP for about $10 at the store (I know I just bought one two days ago).
TheSpaceDude
January 2nd, 2005, 21:40
That has huge security wholes, a better way to do that is:
<?PHP
if (file_exists($_GET['page'])) {
// The file exists, so include...
include $_GET
} else {
// File doesn't exist, so output file does not exist...
echo 'File does not exist;
}
?>
That has the exact same problem, no more secure than the first example :shame:
The correct way of doing this would be:
<?
define('FILES_PATH', './files/'); // The path to your included files.
define('FILES_EXT', '.html'); // The extension to included files.
$g_pageName = baseName($_GET['page']); // Make sure the path is safe.
if (empty($g_pageName))
{
// No page entered, include the default page.
require 'news/news.php';
}
else if (file_exists(FILES_PATH . $g_pageName . FILES_EXT))
{
// A page was entered and it was found, include it.
require FILES_PATH . $g_pageName . FILES_EXT;
}
else
{
// A page was entered but not found, display an error.
exit('The page you requested ("' . $_GET['page'] . '") could not be found!');
}
?>
devonhosting
January 6th, 2005, 10:34
http://www.phpfreaks.com/
are a very good php tutorials
cdmonz
January 16th, 2005, 19:31
I learned php by going to the code library at http://www.phpbuilder.com/ and picking apart the scripts and seeing how they work
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.