Forum Moderators: coopster

Message Too Old, No Replies

page redirection?

         

suresheva31

6:45 pm on Nov 1, 2004 (gmt 0)

10+ Year Member



file name: index.php

echo "<form action='swversion.php' METHOD=POST>";
echo "<input type=hidden name='action'value='swlist'>";
echo "<INPUT TYPE=HIDDEN NAME='entry' VALUE='.'>\n";
echo "<input type='submit' value='List Software' class = 'formstyle'>";
echo "</form>";

Hey guys, I wanted to add something to this little form code; How do i redirect this index.php, once I click on the submit button it will take to me swversion.php as you could see that my action is doin that. I want that to happen after 5 secs or right away. As soon as hit the button, I want to that page to go back to this index.php again.

Suresh

berbluesea

6:58 pm on Nov 1, 2004 (gmt 0)



Hi
you can make this with javascript not with php!

LG

[edited by: jatar_k at 7:15 pm (utc) on Nov. 1, 2004]
[edit reason] removed url [/edit]

suresheva31

7:10 pm on Nov 1, 2004 (gmt 0)

10+ Year Member



do you know where to apply that Javascript in that code. If you do.. can you please let me know.

Thanks

mincklerstraat

8:17 pm on Nov 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



in your 'action' page you can (before there's any output) do this:
header('Location: ht*p://yoursite.com/pageyouwanttogoto.php');

StupidScript

12:06 am on Nov 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why not put the PHP code that will respond to the form on the index.php page and make the action=<?=$PHP_SELF()?>?

Why switch pages at all, if you are just going to go back to the original page?

DaButcher

2:44 pm on Nov 2, 2004 (gmt 0)

10+ Year Member



Ok, what you have to do:

header("HTTP/1.1 301 Moved Permanently");
header("Location: [domain.tld...]
header("Connection: close");

I guess you can make some serverside timer that counts down, before using the header function, but beware:

header must be used before *any* parsing of *anything*.
eg. a simple " " in front of the <?php tag, can cause the error "headers already sent".

*nothing* can be parsed before header().
the 301 fixes the google crawler, so it wont punish you in the pagerank system.

This will not be crawled by the spider, as it will be in the page posted to, not in the page posting, but it's good to have good habits, when programming.

The connection close, fixes some IE error..

jatar_k

5:41 pm on Nov 2, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld DaButcher

DaButcher

6:55 pm on Nov 2, 2004 (gmt 0)

10+ Year Member



Thank you, jatar_k.
I'm active on some other programming forums, but I thought that some days I dont have enough threads to reply to.

I hope this forum will give me some tasks I'll have to use my brain to answer, like the others do.

DaButcher

6:58 pm on Nov 2, 2004 (gmt 0)

10+ Year Member



btw. I forgot one sollution too:

<meta http-equiv=refresh content="5; URL=ht*p://www.domain.tld/">

ps. do not use the meta refresh on pages that google or other spiders searchengines can crawl!

If you do, your pagerank will suffer!
If you wish to make it in a page which is only submitted to, you are safe!

Good luck!