If someone comes to my website, and the url just equals
    domain.com/site/index.php
    or domain/site/
I want to be able to redirect them to
    domain.com/site/index.php?action=showcat&catid=1
I need to know how to do that for the site I am making right now. Using PHPnews, it shows all news and posts on the front page, but I want it to only show a certain category when you visit the site, so that you dont see a clutter of posts from odd categories and such. I came up with this...
( I am still not that great at PHP, so bare with me )
Code:

if ( $action == null ) {

 header(location: index.php?action=showcat&catid=1);

}
the thing is, thats its got some work needs to be done...
Please help me with this, I need this done by Monday Sad !
UPDATE:
    Just got done with a little research and programming and came up with this, but this wont work ethar...
    Code:
    <?php

     $siteurl = $_SERVER['SCRIPT_NAME'];

     if ( $siteurl == "/index.php" ) {
       header("location: index.php?action=showcat&catid=1");
     }

    ?>
    It freaks out and I get the following error:
    Code:
    Warning: Cannot modify header information - headers already sent by (output started at /home2/clubfusi/public_html/index.php:4) in /home2/clubfusi/public_html/index.php on line 9
    Can anyone help me Sad ? I need this finished by tomorrow. I have everthing ready, except this. And once I get this done, then the project will be completed and both me and my client will be happy Very Happy
try this


Code:
Its not quite working, I get the same header error. I need something that changes to index.php?action=showcat&catid=1 if the url is only index.php .

What about if(!isset($_GET['action']))?
You need to make sure that the redirect is before you do any echo()ing or print()ing to the page contents.
KermMartian wrote:
You need to make sure that the redirect is before you do any echo()ing or print()ing to the page contents.


Hence the reason it said "output already started on line whatever" lol - I really wish people would actually READ the error messages and GO to the line it says Rolling Eyes
Kllrnohj wrote:
KermMartian wrote:
You need to make sure that the redirect is before you do any echo()ing or print()ing to the page contents.


Hence the reason it said "output already started on line whatever" 0x5 - I really wish people would actually READ the error messages and GO to the line it says Rolling Eyes
Laughing Exactly - and I think I'm not the first person on the page to mention it. If nothing else, I saw elfprince mention this on SAX.
Why even bother with redirecting? If there's no action, just assume that action=showcat & catid=1
KermMartian wrote:
Kllrnohj wrote:
KermMartian wrote:
You need to make sure that the redirect is before you do any echo()ing or print()ing to the page contents.


Hence the reason it said "output already started on line whatever" 0x5 - I really wish people would actually READ the error messages and GO to the line it says Rolling Eyes
0x5 Exactly - and I think I'm not the first person on the page to mention it. If nothing else, I saw elfprince mention this on SAX.


I did, however it's also important that he changes his redirect statement anyway since the one he had would have brought him to http:///index.php?act=showcat@catid=1 which wouldn't have gone over real well with his webbrowser Wink
KermMartian wrote:
Kllrnohj wrote:
KermMartian wrote:
You need to make sure that the redirect is before you do any echo()ing or print()ing to the page contents.


Hence the reason it said "output already started on line whatever" 0x5 - I really wish people would actually READ the error messages and GO to the line it says Rolling Eyes
0x5 Exactly - and I think I'm not the first person on the page to mention it. If nothing else, I saw elfprince mention this on SAX.


I knew what the error was, I am not that stupid Rolling Eyes . The other problem was solving it with both functions working?

I fixed it before, but the problem was, the if statement was like it was'nt there. I found another way to do it. So it dfoes'nt matter anymore.
Ah, that makes sense. Well, glad you got it all straightened out, and the site looks great.
swivelgames wrote:
I knew what the error was, I am not that stupid Rolling Eyes . The other problem was solving it with both functions working?


Thats a hard question to answer without seeing the whole thing, as neither snippet you posted outputted any text. Rolling Eyes
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement