Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mixing javascript and PHP

Status
Not open for further replies.

inusrat

Programmer
Feb 28, 2004
308
CA
Hi,

i need to create a URL and then redirect to a certain page, How can I do that using PHP? I tried to do do that using PHP/javascript, but i guess it is not working..Is it possible to do that with out geting javascript involved?

Thats what I am trying

<?php
$tx=$_GET['tx'];
?>
<script language="JavaScript">
location.href=orderapproval.php?tx= <?php $tx ?>
</script>




 
wrong command in js...try

echo "<script language='JavaScript'> window.location='summary.php?ccode=$ccode'; </script>";

Bastien

Cat, the other other white meat
 
Yes, you can (and should) do this without js.

How?

You have two ways:
Code:
<META HTTP-EQUIV=Refresh CONTENT="10; URL=http://www.domain.tld/">

The integer in the code above, is how many seconds the browser waits, untill refreshing.

ps. if you use meta refresh with a low integer, you will get penalized by google!

The other way:
Code:
header("HTTP/1.1 301 Moved Permanently"); 
header("location: [URL unfurl="true"]http://www.domain.tld/");[/URL] 
header("Connection: close");

ps. if you want to pass session id, you can simply add the SID at the end:
...domain.tld?<?=SID?>

Good luck :)

ps. I recommend that you use header-location, instead of meta-refresh.
Also, remember you cannot do a header-location in the middle of the page! it has to be done *before* any parsing!

You can however write a redirect function and call it from where-ever in the page.

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top