|
-
Aug 18th, 2007, 08:10 AM
#1
Thread Starter
Lively Member
[RESOLVED]Getting variable from URL for include
Hey all,
I'm designing a sort of CMS system for a dutch non-profit org. but I am kind of stuck now.
I want to retrieve the part in the URL that has a variable in it,Example:
http://domain.com/index.php&about
when the variable is &about I want the page to include about.html in the include statement
Like:
Code:
<?php include("http://domain.com/{&about}"); ?>
If I am not mistaken,
could anyone give me a code snippet that does work? I dont know how the $_get statement works yet but I am sure it has to do with this,
also note,I am not an expert in PHP at all, I am not even at the beginner level.
thanks a bunch in advance.
Last edited by Neo-dark; Aug 18th, 2007 at 09:44 AM.
Reason: Resolved
i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD
Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis
-
Aug 18th, 2007, 08:30 AM
#2
Re: Getting variable from URL for include
You need to use the $_GET[''] variable like you use the $_POST variable
btw the syntax for the url is incorrect in that way.
Code:
This would be correct
http://domain.com/index.php&id=about
The PHP part would look like this
PHP Code:
$myvar = $_GET['id'];
echo $myvar;
//If you use the example URL above, the output would be "about"
Delete it. They just clutter threads anyway.
-
Aug 18th, 2007, 08:44 AM
#3
Thread Starter
Lively Member
Re: Getting variable from URL for include
 Originally Posted by TheBigB
You need to use the $_GET[''] variable like you use the $_POST variable
btw the syntax for the url is incorrect in that way.
Code:
This would be correct
http://domain.com/index.php&id=about
The PHP part would look like this
PHP Code:
$myvar = $_GET['id'];
echo $myvar;
//If you use the example URL above, the output would be "about"
Thanks allot! But its not quite resolved yet,
As soon as I enter an ID the Server gives me a 404, Is this a problem with my server?
i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD
Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis
-
Aug 18th, 2007, 08:48 AM
#4
Re: Getting variable from URL for include
how does your page code look like?
Delete it. They just clutter threads anyway.
-
Aug 18th, 2007, 08:51 AM
#5
Thread Starter
Lively Member
Re: Getting variable from URL for include
 Originally Posted by TheBigB
how does your page code look like?
without the stylesheet its:
Code:
<?php $file = $_GET['id']; ?>
<!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><title>Wij zijn De Verandering - Home</title>
<meta name="description" content="Website van de Officele Nederlandse Be The Change">
<meta name="keywords" content="Be the change nederland,Be the change,Challange day Nederland,Be the change website,Wees de verandering">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<body>
<table width="850" align="center" cellpadding="0" cellspacing="0" style="margin-bottom: 1.0em">
<tr>
<td height="374" valign="top"><table width="850" height="256" cellpadding="0" cellspacing="0">
<tr>
<td height="254" bgcolor="#FFFFFF"><table width="850" height="50" cellpadding="0" cellspacing="0">
<tr>
<td background="images/blackHeader2.jpg" bgcolor="#000000" class="style20"> <span class="style20"><strong><span class="style21"><span class="style52"><span class="style68">Stichting Wij Zijn De Verandering</span></span></span></strong></span></td>
</tr>
</table>
<table width="850" height="35" cellpadding="0" cellspacing="0">
<tr valign="middle">
<td background="images/subBannerB.jpg" bgcolor="#000000">
<span class="style57"> <strong> <img src="images/spacer.gif" width="20" height="1" /></strong><a href="http://www.challengeday.org">Onderdeel van Be The Change</a> <img src="images/spacer.gif" width="535" height="1" /><a href="http://www.wijzijndeverandering.nl/index.php">Home Page</a></span></td>
</tr>
</table>
<table width="850" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/banner.gif" width="850" height="110" /></td>
</tr>
</table>
<table width="850" height="23" cellpadding="0" cellspacing="0">
<tr>
<td background="images/blackFiller.jpg"> </td>
</tr>
</table>
<table width="850" height="598" cellpadding="0" cellspacing="0">
<tr>
<td width="150" height="596" align="center" valign="top" background="images/TEXTback.jpg" bgcolor="#FFFFFF" class="style20"><img src="images/spacer.gif" width="150" height="1" /><br />
<table width="150" cellspacing="0" cellpadding="0">
<tr>
<td align="center" class="style26"><?php include("http://www.wijzijndeverandering.nl/versie2/menu.php"); ?></td>
</tr>
</table>
<td valign="top" background="images/TEXTback.jpg" bgcolor="#FFFFFF" class="style20"><table width="550" height="37" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td align="center" background="images/searchBKGND.gif" bgcolor="#FFFFFF"><span class="style24">::Content::</span></td>
</tr>
</table>
<table width="550" height="128" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><blockquote class="style28"><br />
<?php
include("http://www.wijzijndeverandering.nl/{$file}.php");
?>
__________________________________________________________________</span></blockquote></td>
</tr>
</table>
<br /></td>
<td width="150" align="center" valign="top" bgcolor="#FFFFFF" class="style20"><table width="150" height="31" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td background="images/blackFiller.jpg"><div align="center" class="style40">Wie Is Wie </div></td>
</tr>
</table>
<img src="images/dvertBlock.gif" width="150" height="550" /><br />
<br />
<br /> </td>
</tr>
</table>
<table width="850" cellspacing="0" cellpadding="0">
<tr>
<td background="images/blackFiller.jpg" class="style20"> </td>
</tr>
</table>
<table width="850" cellspacing="0" cellpadding="0">
<tr>
<?php include("http://www.wijzijndeverandering.nl/versie2/footer.php"); ?>
<td background="images/searchBKGND.gif" bgcolor="#FFFFFF" class="style20"> </td>
</tr>
</table>
<div style="font-size: 0.8em; text-align: center; margin-top: 1.0em; margin-bottom: 1.0em;"></div>
<a href="index.php">index</a>
</body>
</html>
i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD
Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis
-
Aug 18th, 2007, 08:54 AM
#6
Re: Getting variable from URL for include
try this
PHP Code:
include("http://www.wijzijndeverandering.nl/$file.php");
instead of
PHP Code:
include("http://www.wijzijndeverandering.nl/{$file}.php");
Delete it. They just clutter threads anyway.
-
Aug 18th, 2007, 09:00 AM
#7
Thread Starter
Lively Member
Re: Getting variable from URL for include
 Originally Posted by TheBigB
try this
PHP Code:
include("http://www.wijzijndeverandering.nl/$file.php");
instead of
PHP Code:
include("http://www.wijzijndeverandering.nl/{$file}.php");
I'm still getting a 404.
I changed the code as you said.
Here is the link
http://wijzijndeverandering.nl/versi...php&id=content
when I go to http://wijzijndeverandering.nl/versie2/index.php I get an error aswell(due to no ID variable bieing passed on, I should make an If statement for this right?)
________________
EDIT:
found it! I forgot to place a question mark next to Index.php, my bad,sorry.
Still open because of the If statement,
Last edited by Neo-dark; Aug 18th, 2007 at 09:05 AM.
Reason: got it
i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD
Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis
-
Aug 18th, 2007, 09:10 AM
#8
Re: Getting variable from URL for include
The problem is that you're actually opening
Code:
http://www.wijzijndeverandering.nl/content.php
which doesn't exist.
it would work if you'd change the code to
PHP Code:
include("http://www.wijzijndeverandering.nl/versie2/$file.php");
Delete it. They just clutter threads anyway.
-
Aug 18th, 2007, 09:43 AM
#9
Thread Starter
Lively Member
Re: Getting variable from URL for include
 Originally Posted by TheBigB
The problem is that you're actually opening
Code:
http://www.wijzijndeverandering.nl/content.php
which doesn't exist.
it would work if you'd change the code to
PHP Code:
include("http://www.wijzijndeverandering.nl/versie2/$file.php");
Works,Resolved.
i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD
Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|