forum.php?linkhere
Moderator: General Moderators
- dull1554
- Forum Regular
- Posts: 680
- Joined: Sat Nov 22, 2003 11:26 am
- Location: 42:21:35.359N, 76:02:20.688W
forum.php?linkhere
i'm writing a forum and i wanted to make it so the catagories would link to another section of forum.php, i was wondering how to make a link like forum.php?php I know that the "php" has to be defined somewhere else, but thats what i dont know how to do that, i looked in the manual and i just can't figure it out, any help would be greatly appreciated!
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
- dull1554
- Forum Regular
- Posts: 680
- Joined: Sat Nov 22, 2003 11:26 am
- Location: 42:21:35.359N, 76:02:20.688W
maybe i'm not being clear enough,
I want to do this
forum.php
I want to do this
forum.php
Code: Select all
//code here
Print <<<END
<a href='forum.php?thread1' target='main'>thread 1</a>
END;
//define thread1
$thread1 = "blah";//i don't know if this is how i would do this, could somone please help
//php-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
still not understanding, so ill just help u with a few other things while u try to explain it to my stupid mind.. :p
if you're only echoing one line, theres no need to use here.doc.
also, END is a bad value for here.doc, as it is used in text a good amount (ie. the end, etc)
use something that you would never type for the value, ie:
EOT means "End Of Text" and is used a lot (i also believe its the example at php.net)
is this going to be where all the topics are listed? like where all the topic names go, and u click it to bring you to the topic? im still not quite understanding.. sorry..
Also another thing to remember about here.doc that i forget a lot, it needs to have NO spaces infront of it (can't be tabbed in, etc..)
so
wont work, but..
will 
if you're only echoing one line, theres no need to use here.doc.
also, END is a bad value for here.doc, as it is used in text a good amount (ie. the end, etc)
use something that you would never type for the value, ie:
Code: Select all
echo <<EOT
<a href="forum.php?t=$thread" target="main">Thread 1</a>
EOT;is this going to be where all the topics are listed? like where all the topic names go, and u click it to bring you to the topic? im still not quite understanding.. sorry..
Also another thing to remember about here.doc that i forget a lot, it needs to have NO spaces infront of it (can't be tabbed in, etc..)
so
Code: Select all
echo <<<M43M
my HTML stuFFF!
M43M;Code: Select all
echo <<<M43M
my HTML stuFFF!
M43M;I'm not quite sure what you mean either but maybe you're looking for query strings? Something like this?
If that is what you are looking for then on the forum.php you could do this:
Edit:
Just saw your above post, you want to do something like this:
then in the PHP you can have something like:
Code: Select all
http://www.example.com/forum.php?forumid=3&topicid=8Code: Select all
<?php
echo "Forum ID:" . $_GET['forumid']; //will echo 3
echo "Topic ID:" . $_GET['topicid']; //will echo 8
?>Just saw your above post, you want to do something like this:
Code: Select all
http://www.example.com/forum.php?page=homeCode: Select all
<?php
if($_GET['page'] == "home")
{
include("includes/home.php");
//OR
// put all HTML inside these brackets
}
?>
Last edited by DuFF on Wed Dec 03, 2003 5:25 pm, edited 1 time in total.
Actually, just a tip, like IPB or phpBB, you should have a showforums.php and showtopic.php just to keep the mess a little more tidy. You'd somewhat go around:
// show forums (list all if none selected)
Hope it helps, let me know how the forum goes.
-Nay
// show forums (list all if none selected)
Code: Select all
<?php
$forum = $_GET['forum'];
// check if forum exists
$sql = "SELECT id FROM forums WHERE id = '$forum'";
$res = mysql_query($sql, $connection) or die(mysql_error());
$nrc = mysql_num_rows($res);
if(isSet($forum) && !empty($forum) && is_numeric($forum) && $nrc == 1):
// show the forum
else:
// show the lists of all forums
endif;
?>-Nay
I know this post is over but look at my way:
Code: Select all
<a href="index.php?op=home">Home</a>
Index.php:
<?php
include "$op.php"; // $op holds home. So $op.php is home.php
?>
That way there is no way you direct somewhere else.
You can even pass variables to home.php like:
<a href="index.php?op=home&do=view">Home</a>HOLD it there. If you do that some one can just do a:
index.php?op=/var/www/httpd/httpd.conf
Doing, that PHP will include that file, meaning that the user will be able to see your httpd.conf. Not only httpd.conf, maybe your other files as well. So it's best to do:
index.php?op=home
They're even more ways with CASE and other statements. Your code is not wrong but it's just a big security risk.
-Nay
index.php?op=/var/www/httpd/httpd.conf
Doing, that PHP will include that file, meaning that the user will be able to see your httpd.conf. Not only httpd.conf, maybe your other files as well. So it's best to do:
index.php?op=home
Code: Select all
<?php
$op = $_GET['op']; // you can't use your way when registered_globals are off
// then
$allowed = array("home", "about");
if(in_array($op, $allowed)):
include $op . ".php";
else:
echo "you can't view that file";
exit;
endif;
// or
if($op == "home"):
include "home.php";
elseif($op == "about"):
include "about.php";
else:
echo "you can't do that";
exit;
endif;
?>-Nay
- Sevengraff
- Forum Contributor
- Posts: 232
- Joined: Thu Apr 25, 2002 9:34 pm
- Location: California USA
- Contact:
you can do something like this:
stuff.php?dothis
but it's not very expandable. the way you want it to work, you'd have to look at $_SERVER['QUERY_STRING'], and maybe do something like this:
forum.php?thread1
It's a lot easier just to do forum.php?thread=1
stuff.php?dothis
Code: Select all
if( isset($_GET['dothis']) ) {
echo "I am doing stuff";
}forum.php?thread1
Code: Select all
if( strpos($_SERVER['QUERY_STRING'], 'thread1')) {
$thread_id = substr($_SERVER['QUERY_STRING'], 6);
echo "Viewing thread: $thread_id";
}HOLD it there. If you do that some one can just do a:
index.php?op=/var/www/httpd/httpd.conf
Doing, that PHP will include that file, meaning
No.
You see what ever the index.php?op=...be it will end up with a .php extension. So index.php?op=/var/www/httpd/httpd.conf
will become: index.php?op=/var/www/httpd/httpd.conf.php
No file.. No inclusion
Correct me if i am wrong...