Jump to content

Archived

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

AbydosGater

My Script Has A Few Bugs..

Recommended Posts

Ok, i made a quick page for testing my script...
[a href=\"http://www.stargate.hostyw.com/testing.php\" target=\"_blank\"]HERE[/a]
Within the table on this page is the following...
[code]
<?PHP

    //Checking page vars ) if none, making 'INDEX'
  if (!isset($_GET['page'])) {
    $page = "index";
  } else {
    require($_GET['page'].".php");
    print "this should work";
  };
  

    //End Checking page vars ) if none, making 'INDEX'    
    ?>
[/code]

ok and this seams to work, kinda, if you go to [a href=\"http://www.stargate.hostyw.com/testing.php?page=index\" target=\"_blank\"]HERE[/a] it works

but the lines of the IF statement are not working, when you go to the www.stargate.hostyw.com/testing.php file no vars in the url, you just get a page, not require, it does not make $page = "index"

[code]
  if (!isset($_GET['page'])) {
    $page = "index";
  }
[/code]


ok and there is something wrong with my last bit of security...

[code]
if ($page != 'index' || $myvar != 'password' || $myvar != 'value3' || $myvar != 'value4')
    {
    $page = "index";
     };
[/code]

Because if you type in something stupid in the domain like, [a href=\"http://www.stargate.hostyw.com/testing.php?page=PIZZA\" target=\"_blank\"]THIS[/a]

it just shows the html of the page, it does not reset to index!

Can anyone see why these problems are occuring?
Thank You So Much
Andrew Butler


IF YOUR HAVING PROBLEMS UNDERSTANDING ME, PLEASE READ [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=88480\" target=\"_blank\"]This[/a] Its a pervious topic about this script!

Share this post


Link to post
Share on other sites
[!--quoteo(post=357727:date=Mar 23 2006, 06:57 PM:name=AbydosGater)--][div class=\'quotetop\']QUOTE(AbydosGater @ Mar 23 2006, 06:57 PM) [snapback]357727[/snapback][/div][div class=\'quotemain\'][!--quotec--]
IF YOUR HAVING PROBLEMS UNDERSTANDING ME, PLEASE READ
[/quote]

without being rude, the only problem i have is posting a (possible) solution in your one topic only to find you've started another about exactly the same thing.

Share this post


Link to post
Share on other sites
If you read the last post in my other topic it explains why i made a new topic,
the other one was asking if there was a tutorial for something and got off track, so i started a new one for this script! as the other topic is answered, this is a new one!

I appoligise but that is what i though was the best thing to do!

Share this post


Link to post
Share on other sites
[!--quoteo(post=357743:date=Mar 23 2006, 07:31 PM:name=AbydosGater)--][div class=\'quotetop\']QUOTE(AbydosGater @ Mar 23 2006, 07:31 PM) [snapback]357743[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I appoligise but that is what i though was the best thing to do!
[/quote]

fair comment. I ain't God around here so no need for apologies to me, but either way I posted a possible solution on your other topic. I'd cut/copy and paste, but repeating myself in two different places would make me a hypocrite lol

(summary: swap your OR (||) for AND (&&) in your check youre having problems with.

Share this post


Link to post
Share on other sites
Ok, I tryed it and now when i put in a value not listed, i just get an error message not the index!?

Any other ideas?

Share this post


Link to post
Share on other sites
[!--quoteo(post=357749:date=Mar 23 2006, 07:53 PM:name=AbydosGater)--][div class=\'quotetop\']QUOTE(AbydosGater @ Mar 23 2006, 07:53 PM) [snapback]357749[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Ok, I tryed it and now when i put in a value not listed, i just get an error message not the index!?

Any other ideas?
[/quote]

do me a favour, post your full block of code (all in one piece) including all your changes.

Share this post


Link to post
Share on other sites
Here is the entire source for the page...


[code]
<html>
<head>
<title>Testing Abydosgater's Paging Program</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#990000" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FF0000">
<p>MY WEB CONTENT HERE</p>
<p>&nbsp;</p>
<p>BLAH</p>
<table width="100%" border="1" cellspacing="1" cellpadding="1">
  <tr>

    <td height="512">
    <p>
    <?PHP

    //Checking page vars ) if none, making 'INDEX'
  if (empty($_GET['page'])) {
   require("index.php");
  } else {
    require($_GET['page'].".php");
    print "this should work";
  };
  
if ($page != 'index' && $page != 'password' && $page != 'value3' && $page != 'value4')
{
  $page = "index";
};

    //End Checking page vars ) if none, making 'INDEX'    
    ?>
    </p></td>
  </tr>
</table>
<p>&nbsp;</p>
<p>BLAH</p>
</body>
</html>
[/code]

Anything else i can do?

Share this post


Link to post
Share on other sites
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Anything else i can do?
[/quote]

yep. youre including the check to make sure it's the right page, but youre not using the result to do anything. i'll ignore your HTML and just look at the PHP. sorry if i get carried away with anything:

[code]
<?php
$valid_pages = array('index', 'password', 'value3', 'value4');

$page = $_GET['page'];
if (in_array($page, $valid_pages))
{
   require($page.'.php');
}
else
{
   require('index.php');
}
[/code]

ok, it's not perfect and will still need alot of checking/testing, etc, but it should get you on your way.

Share this post


Link to post
Share on other sites
GREAT,
right this works,
i am going to use it as the very basis for my script,
with a few additions and modifications this is Exactly what i need,
Thank You SOOOOO Much!
You Were A Great Help

Share this post


Link to post
Share on other sites
[!--quoteo(post=357763:date=Mar 23 2006, 08:34 PM:name=AbydosGater)--][div class=\'quotetop\']QUOTE(AbydosGater @ Mar 23 2006, 08:34 PM) [snapback]357763[/snapback][/div][div class=\'quotemain\'][!--quotec--]
GREAT,
right this works,
i am going to use it as the very basis for my script,
with a few additions and modifications this is Exactly what i need,
Thank You SOOOOO Much!
You Were A Great Help
[/quote]

hehe not a problem glad to help.
Cheers
Mark

Share this post


Link to post
Share on other sites

×

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.