• Be sure to join the discussion on our discord at: Discord.gg/serebii
  • If you're still waiting for the e-mail, be sure to check your junk/spam e-mail folders

Problems with PHP!

Misty-chan

Boulder Trainer
Hii!!! I had a site of aaml and I´m changing it for php ( only the index page ). And I´m puting a code for all links open in the same place ( like iframe ).

This code make appear de contents of site inside of index page... and work...
PHP:
<?php if(empty($page)) 

{ 

include("noticias.php"); 

} 

else { include("$page.htm"); 

} 

?>

And this code is for links of site:

PHP:
index.php?page=banners

But when a click in a link of site, nothing happen xP ! The index page is in php... I don´t know explain it very well hehehe ^^' . Someone could help me? Pleasseee?!?
 

JKaizer

Ready for a new day
Not sure if this would work, but go ahead and try it
PHP:
<?php 

if (!$page) { include("noticias.php"); } 
else { include("$page.htm"); } 

?>
 

Misty-chan

Boulder Trainer
Thanks for help me, but the problem still the same. The code make show the page of middle, but the links of table don´t open... I don´t know why x] .
 

Dragonfree

Just me
Umm... is that all the PHP you have?

Because you need to define $page as $_GET['page'] somewhere before you can use that...
 

JKaizer

Ready for a new day
I didn't think that'd it work, I was just messing with your code a bit.

Try using this, as it works for everyone else:
PHP:
<?php

$news = "noticias.php";
$error = "error.htm CHANGE THIS I GUESS";
$ext = ".htm";

if(!isset($_GET['page'])){
include $news;
}
elseif($_GET['page'] == "main") {
include $news;
}
elseif(isset($_GET['page']) && file_exists($_GET['page'].$ext)){
include $_GET['page'].$ext;
}
else{
include $error;
}

?>
 

Misty-chan

Boulder Trainer
Thanks very much, Dragonfree and JKaiser for help me! I was getting crazy with this code... the code that JKaiser show works very well!!! Hehehehehe... now I can breath again xP

Thanks! Thanks! Thanks!
 

JKaizer

Ready for a new day
Glad it's working for you now. ^_^

*chuckles as more and more people use my code* =D
 

Misty-chan

Boulder Trainer
Oh my god!!! I have a new problem!!! Hehehehe... x]

Now the links open in a new window... example:

If a enter in a link called 'banners', work right. But if a enter in a link inside of page banner open in a new window! What I gonna do now?

Sorry for be bore T.T !
 
Last edited:

Dragonfree

Just me
Are you sure the links don't have target="_blank" in their attributes?
 

Virtual Headache

*~*~*~*~*~*~*~*~*
Instead of
HTML:
<A 
href="project.php?page=enquetes">Enquetes</A>
try using only this:
HTML:
<A 
href="?page=enquetes">Enquetes</A>
on all of your links.

I recommend trying it out for only one of the not working links first, then for the others, since I'm not completely sure if it will help.

You should also take a look at CSS.
You use a lot of HTML code which wouldn't be necessary if you used CSS and would make making the layout a little easier ;)
 
Last edited:

Misty-chan

Boulder Trainer
No... the others links ( .htm ) is normal:

by example: "page.htm" don´t have target.
 

Misty-chan

Boulder Trainer
Well, before I was using:

PHP:
?page=banners

But all links are open in a new window! This code:

PHP:
project.php?page=banners

Only the links of banners open in a new window.

I don´t know very much CSS, but I gonna read a tutorial of this ^^ ! Maybe it gonna help me a little...
 

JKaizer

Ready for a new day
<DIV
style="Z-INDEX: 1; LEFT: 0px; WIDTH: 127px; POSITION: absolute; TOP: 186px; HEIGHT: 1190px">
<P align=center></P><FONT face=Arial><FONT size=2><FONT color=#7f7f7f><FONT
color=#7f7f7f><STRONG><FONT face=Tahoma><FONT size=1><FONT color=#7f7f7f>

<P align=right></FONT></FONT></FONT></STRONG></FONT></FONT></FONT></FONT><A
href="project.php?page=banners"><FONT face=Tahoma color=#333333 size=1>Banners /
Buttons</FONT></A><BR><A href="project.php?page=parceria"><FONT face=Tahoma color=#333333
size=1>Fazer Parceria / Parceiros</FONT></A><BR><FONT face=Tahoma size=1><A
href="project.php?page=trabalheaqui">Trabalhe Aqui</A><BR><A
href="project.php?page=enquetes">Enquetes</A></FONT><BR>
That's just a bit from your navigation. @_@

I'd suggest trying to simply down that code a bit, sot hat it's actually readable. In it's current state, I can't find what's making the links go to a new page.
 

Misty-chan

Boulder Trainer
I found one error! This:
Code:
<BASE target=iypp>

Yeah was one target problem =XXXX

Now the links of menu work! This things drives me crazy... hehehehe...
But still had a problem... Example: if I enter in section 'fanfics', and after I enter in some link inside of 'fanfics' open in a new window without target ._.' .

My problems don´t go away... why sad!

Do you are understand me? My english is very bad ;_;
 

Misty-chan

Boulder Trainer
Well, try enter in the link fanfics ( fanshrine > fanfics ). In the end of page 'fanfics' have a link, enter in it. Well, like you can see the links open in all page, no in the same place of fanfics O.O' ... when I change the link for:

PHP:
?page=link

Works well, but my site had so many links... More than 80 o.o' ... I want still with others links like html normal.

Somebody save mee... ;_;
 
Last edited by a moderator:

Magma Leader Maxie

Non caedor caedo
I would like to note that using $_GET to receive an id number probably isn't a good idea unless it's really necessary (pages from MySQL databases, in which case the request string at the end of the URL holds a parameter for a query).

People often get annoyed in my experience because of confusing and often hard to remeber URLs.

[noparse]http://www.something.com/index.php?item=42&bannertype=pink&atotallyrandomnumber=32472347209[/noparse]

^ This is terrible ;_;

However, if there's a necessary value to be taken into consideration...

[noparse]http://www.something.com/articles.php?id=67[/noparse]

^ This is ok, if for example "articles.php" is a script which allows users to post their articles and read others.
 
Last edited:
Top