Help

CascadesAdmin

New Member
Messages
87
Reaction score
0
Points
0
Hey, I ned some help with this:

PHP:
if(isset($_GET['p']))
{
     $p = $_GET['p'];
     include($p.'.php');
}
Where do I put it. I am trying to get it to work on this site: http://www.cascades.exofire.net i would also like it to be a=name instead of p=name.

Help please!

``Frodo6695``
 
Last edited:

lambada

New Member
Messages
2,444
Reaction score
0
Points
0
For it to be 'a' and not 'p' then simply use
PHP:
if(isset($_GET['a']))
{
     $a = $_GET['a'];
     include($a.'.php');
}

Although I must say that this is a very insecure way of accessing a page.As someone could include ANY PHP file and not just the ones you want them to.

As for where you put it, could you post the source of your page (the server is down atm).
 

CascadesAdmin

New Member
Messages
87
Reaction score
0
Points
0
Which page?
the home one?

HTML:
<!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=iso-8859-1" />
	<meta http-equiv="Content-Style-Type" content="text/css" />
	<title>Cascades Band</title>
	<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
<div id="wrapper">
	<ul id="nav">
		<li><a href="http://www.cascades.exofire.net/index.php?a=idx">Home</a></li>
		<li><a href="http://www.cascades.exofire.net/index.php?a=band">Band</a></li>
		<li><a href="http://www.cascades.exofire.net/index.php?a=shows">Shows</a></li>
		<li><a href="http://www.cascades.exofire.net/index.php?a=contact">Contact</a></li>
		<li><a href="http://www.cascades.exofire.net/index.php?a=extras">Extras</a></li>
	</ul>
	<h1><a href="/"><img src="images/logo1.gif" width="118" height="25" alt="Cascades Band" /></a></h1>
	<div id="body">
		<div id="bodyi">
			<div id="bodyj">
				<div id="sidebar">
					<div class="content">
						<h2>Info</h2>
						<p>This site is currently under construction.</p>











						<p class="readmore"><a href="http://www.freewebsitetemplates.com">Read More</a></p>
					</div>
					<div class="divider"></div>
					<div class="content">
						<h2><a href=http://news.cascades.exofire.net/show_news.php>Latest News &amp; Updates</a></h2>



						<p class="readmore"><a href="http://news.cascades.exofire.net/rss.php">Read More</a></p>
					</div>
				</div>
				<div id="content">
					<img src="images/construction2.jpg" width="346" height="234" alt="Under Construction" />
					<div class="content">
						<h2>Latest Album</h2>
						<p>No Albums Yet, Site under Construction.</p>
						<p class="readmore"><a href="http://www.freewebsitetemplates.com">Read More</a></p>
						<div class="divider"></div>
						<h2>Hit List</h2>
						<table summary="track downloads" border="0" cellspacing="0">
						<tr>
							<th width="55%">Tracks</th>
							<th>Album</th>
							<th class="hidden">Dowload links</th>
						</tr>
						<tr>
							<td>None</td>
							<td>None</td>
							<td class="download"><a href="http://www.freewebsitetemplates.com">Download</a></td>
						</tr>
						<tr>
							<td>None</td>
							<td>None</td>
							<td class="download"><a href="http://www.freewebsitetemplates.com">Download</a></td>
						</tr>
						<tr>
							<td>None</td>
							<td>None</td>
							<td class="download"><a href="http://www.freewebsitetemplates.com">Download</a></td>
						</tr>
						<tr>
							<td>None</td>
							<td>None</td>
							<td class="download"><a href="http://www.freewebsitetemplates.com">Download</a></td>
						</tr>
						</table>
						<p class="readmore"><a href="http://www.freewebsitetemplates.com">More Tracks</a></p>
					</div>
				</div>
				<div class="clear"></div>
			</div>
		</div>
	</div>
	<p id="power">Powered by <a href="http://www.freewebsitetemplates.com">Free Website Templates</a></p>
</div>
</body>
</html>

and do you have a more secure way of doing this?
Edit:
I am making a new design I have the template up for now.
 
Last edited:

Corey

I Break Things
Staff member
Messages
34,553
Reaction score
204
Points
63
I don't believe it can be secured doing it the way you have it, the way you have it uses GET to allow the user to pass whatever they want to the script.
 

t2t2t

New Member
Messages
690
Reaction score
0
Points
0
Hmm, sounds familiar...
In order to do that, you would do something like:
PHP:
if(isset($_GET['p']))
{
     $p = $_GET['p'];
     include($p.'.php');
}
"$p" would be your page. So if this script was called index.php, you'd do index.php?p=pizza to include the page: pizza.php

Does that answer your question?

2 CascadesAdmin: *sigh* Thats basic php, so if you have questions, check this first
 
Last edited:

CascadesAdmin

New Member
Messages
87
Reaction score
0
Points
0
yeah, its not like they have that exact code on the page. and I just asked for help with it...
 

Zenax

Active Member
Messages
1,377
Reaction score
4
Points
38
Gimme a week (its when i return home) and I will send you an old script I used for that sort of thing. I was told it was secure!
 

deadimp

New Member
Messages
249
Reaction score
0
Points
0
Think out your different methods:
> Have some sort of filemask criteria that must be met, something using regex or just simple string manipulation
> Make a list of 'accepted' files, and make sure those are the only ones that can be accessed by that specfic include. With this method, you can associate other information with the file, stuff like the title.
This is the high-level, concept part of the design, and I'm going to leave it up to you to implement it.
 

t2t2t

New Member
Messages
690
Reaction score
0
Points
0
You could try using some kind of non-existng file extension for pages (Php can include any filetype that uses .txt format), like *.page

I use for my current site .txt files for pages (Example: On site - Source)
 

deadimp

New Member
Messages
249
Reaction score
0
Points
0
The only problem with using different include name file extensions is that people will be able to view the source, unless you set an .htaccess file to disallow them. However, that is a interesting solution.

You could try using some kind of non-existng file extension for pages (Php can include any filetype that uses .txt format), like *.page

I use for my current site .txt files for pages (Example: On site - Source)
 
Last edited:

t2t2t

New Member
Messages
690
Reaction score
0
Points
0
The only problem with using different include name file extensions is that people will be able to view the source, unless you set an .htaccess file to disallow them. However, that is a interesting solution.
Put it in a "database" folder and have following .htaccess?
Code:
deny from all
(On a completely unrelated note, how come i end up using scripts from my offers script a-lot?! (Don't ask))
Php seems to ignore apache htaccess
CascadesAdmin said:
so I have my index.php but I cant create 2.
If you want to just get content of page (nothing else to change) put these lines in where content will be added in.
 

CascadesAdmin

New Member
Messages
87
Reaction score
0
Points
0
but how to I make it so like a=idx will display the index page and a=band will show that page?
 

Zenax

Active Member
Messages
1,377
Reaction score
4
Points
38
use this script:

PHP:
if( isset($HTTP_GET_VARS['a']) || isset($HTTP_POST_VARS['a']) )
{
    $a = ( isset($HTTP_GET_VARS['a']) ) ? $HTTP_GET_VARS['a'] : $HTTP_POST_VARS['a'];
    $a = htmlspecialchars($a);
}
else 
{
    $a = "";
}

switch( $a )
    {   
			
		case "idx":
		include("index.php");
		break;
		
        case "band":
        include("band.php");
        break;

	   // The default page to load, when website is started.
	   default:
	   include("index1.php"); 
	   break;


}

this creates:

switch.php?a=idx which will include the index.php page so it will show.

second is

switch.php?a=band which will include the band.php page so that will show.

Hope this is useful, and I have been told it is secure, so I hope this helps yah!
 
Last edited:
Top