Jump to content

(Please help) Coding & php url/linking problem!


hugh90

Recommended Posts

Hi, I’m very bad at php and I need your expertise please.

Example, this is how my files are linked.

>> www.site.com/?id=file/file/page

This is a very bad linking system and so inflexible, it only works as long as pages are literally the same as the above example URL is.

But if I were to install a php script (formmail script, quiz scripts, etc..) basically anything that requires submission, a link to be pressed, scripts that require .include codes' to be placed in my php pages, then it doesn’t work and goes back to homepage.php (as specified in the code below).

I’m guessing this happens because the link by those php scripts generate a link/url to a requested file (that even already exists and should link it) but fails to work since it only reads url’s that are coded as the above example.

I also think the php coding below is also to blame, for some reason it thinks the whole php scripting/linking world revolves around URL’s that are linked such as the above example.

This is what I have in the index.php page where I want the dynamic pages to show:

<?php
If(file_exists($_GET['id'].".php"))
{include($_GET['id'].".php");}
else
{include("homepage.php");}
?>


Please fix the above code (or do anything) so that it is more flexible.  ???

Thank you.
url from a index page or any page properly.

know we no that we have set in the link this condition cmd=file
we know goto the page to get that condition.
[code]
<a href="where_ever.php?cmd=file">go to the file </a>
[/code]

this is on the page that the what_ever link points to.
[code]
<?php

if($_GET['cmd']=="file"){
what ever you want to do with the match from the link
}else{
echo " sorry your link did not match this condition";
}
?>
[/code]

[b]ps be very careful when playing around with the $_GET satament as it is only secure as shown above with a condition set ok.[/b]
[quote author=redarrow link=topic=104064.msg414926#msg414926 date=1155463136]

[code]
<?php

if($_GET['cmd']=="file"){
what ever you want to do with the match from the link
}else{
echo " sorry your link did not match this condition";
}
?>
[/code]


[/quote]

Do I just straight replace the above code with my code below?

[code]
<?php
If(file_exists($_GET['id'].".php"))
{include($_GET['id'].".php");}
else
{include("homepage.php");}
?>
[/code]


Sorry my understanding of php is non-existent :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.