note 21204 added to language.variables.predefined

From: Date: Thu, 02 May 2002 23:25:06 +0000
Subject: note 21204 added to language.variables.predefined
Groups: php.notes 
Request: Send a blank email to php-notes+get-30109@lists.php.net to get a copy of this message
I was faced with the problem of turning an ASP website into a PHP/ASP combined website. ASP content provided from the UK, PHP content provided from Holland. I stuffed all the ASP content in an "iframe" but then had to forward all form queries in "POST" method to the internal frame, because the ASP scripts did not accept GET queries. I think the solution is interesting, at least: it works for me and I'm once again stunned by the beauty & simplicity of PHP to solve these (at first glance) complicated problems. With a little help of some of the user contributions on php.net of course... The only thing the UK editors had to do was replace the targetpage.asp they would normally link or POST to with: "http://www.theNLsite.com/content.php?link=targetpage.asp". The page in the "iframe" would then be called like this: echo "<IFRAME SRC=\"http://www.theUKsite.com/$link\" name=\"content\" width=\"100%\" height=\"3000\" MARGINWIDTH=\"0\" MARGINHEIGHT=\"0\" SCROLLING=\"no\" FRAMEBORDER=\"0\">\n"; echo "</IFRAME>\n"; The following was in content.php to forward all queries in POST method: if($REQUEST_METHOD == "GET"){ $vars = explode("&",$HTTP_SERVER_VARS['QUERY_STRING']); $x = count($vars); for($i=0;$i<$x;$i++){ $pass = explode("=",$vars[$i]); if($pass[0] == "link"){ echo "<form name=\"GoToUK\" method=\"post\" action=\"http://www.theUKsite.com/$pass[1]\" target=\"content\"><br>\n"; }elseif($pass[0] == "submit"){ echo "\n"; }else{ echo "<input type=\"hidden\" name=\"$pass[0]\" value=\"$pass[1]\"><br>\n"; } } } if($REQUEST_METHOD == "POST"){ while(list($k, $v) = each($HTTP_POST_VARS)){ if ($k == "link"){ echo "<form name=\"GoToUK\" method=\"post\" action=\"http://www.theUKsite.com/$v\" target=\"content\"><br>\n"; }elseif($k == "submit"){ echo "\n"; }else{ echo "<input type=\"hidden\" name=\"$k\" value=\"$v\"><br>\n"; } } } echo "<script language=\"JavaScript\">\n"; echo "<!--\n"; echo "if(document.all){\n"; echo "setTimeout(\"RNtoUK();\",1000);\n"; echo "}\n"; echo "//-->\n"; echo "</script>\n"; echo "</form>\n"; In this javascript I set a timeout of 1000 milliseconds to allow the iframe to actually become one - else the file opens in a new window, what I do not want to happen. In the HEAD section I included a javascript that submitted the "GoToUK" form secretly to the "iframe" which then would show the requested UK content. function RNtoUK() { document.GoToUK.submit(); } Hey: I'm a beginner, let me be proud for a change... -- http://www.php.net/manual/en/language.variables.predefined.php http://master.php.net/manage/user-notes.php?action=edit+21204 http://master.php.net/manage/user-notes.php?action=delete+21204 http://master.php.net/manage/user-notes.php?action=reject+21204

« previous php.notes (#30109) next »