Jump to content


Photo

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


  • Please log in to reply
3 replies to this topic

#1 hugh90

hugh90
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 13 August 2006 - 09:12 AM

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.

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 13 August 2006 - 09:48 AM

www.site.com/?id=file/file/page
/ is for a new folder
if you want the variables
ID = FILE
File = PAGE
which I think if your goal
then
www.site.com/?id=file&file=page
Tell me the problem, I will try tell you the solution

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 August 2006 - 09:58 AM

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.
<a href="where_ever.php?cmd=file">go to the file </a>

this is on the page that the what_ever link points to.
<?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";
}
?>

ps be very careful when playing around with the $_GET satament as it is only secure as shown above with a condition set ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 hugh90

hugh90
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 13 August 2006 - 07:24 PM


<?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";
}
?>



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

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


Sorry my understanding of php is non-existent :(





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users