Javascript inside PHP for redirect

Status
Not open for further replies.

stodge

Ars Tribunus Militum
1,907
I'm trying to add some Javascript into my PHP to redirect a page after a user has posted a new topic in a forum.

Currently the user has to click a link to view their topic, which is one click too many for liking.

I have this code:

code:<HR>
Code:
$to =   "<script language=\"JavaScript\">"
      . "location.href='modules.php?op=modload&name=Forum&file=viewtopic&topic=$topic_id&forum=$forum';"
      . "</script>";

print "$to";

This code is inside newtopic.php.

The redirect doesn't work as I get this:

code:<HR>
Code:
Warning:  Failed opening 'modules//.php' for inclusion (include_path='.:/usr/share/php') in /home/e-smith/files/primary/html/modules.php on line 40

Can anyone see anything that is obviously wrong?

Thanks
 
Javascript should maintain the URL encode, I've passed parameters that way before. but as for the problem, it looks like it's on the PHP end, not the Javascript end.

More than likely a logic problem.... I cut the <'s off the script tags and printed the URL, and it prints fine on php4 (assuming the variables are there and all that fun stuff).

wish I could help more,

Jher
 
Status
Not open for further replies.