Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Passing variables from ASP to PHP
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Passing variables from ASP to PHP

 Post Reply Post Reply Page  <12
Author
ctscott View Drop Down
Senior Member
Senior Member


Joined: 27 May 2003
Location: United States
Status: Offline
Points: 246
Post Options Post Options   Thanks (0) Thanks(0)   Quote ctscott Quote  Post ReplyReply Direct Link To This Post Posted: 20 February 2006 at 2:14pm

yeah, same session.  i just couldn't come up with a way to get PHP to read an ASP Session variable.

______________________
College Football Trivia
Back to Top
wistex View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 30 August 2003
Location: United States
Status: Offline
Points: 877
Post Options Post Options   Thanks (0) Thanks(0)   Quote wistex Quote  Post ReplyReply Direct Link To This Post Posted: 03 March 2006 at 9:48am
One thing that you could do is embed one page into another page.  Even though they are different languages, you can still do that and pass variables.  I did this with one PHP script that I did not want to rewrite in ASP.  I used an Window's XHTML control to embed the PHP page.  Variables collected on the ASP page (some via the query string) are passed to the PHP page.
 

<%
Function GetHTML(strPage)
On Error Resume Next
Set objXMLHttp = Server.CreateObject ("Microsoft.XMLHTTP")
objXMLHttp.Open "GET", strPage ,False,"",""
objXMLHttp.Send
If Err.Number = 0 Then
If objXMLHttp.Status = 200 then
GetHTML = objXMLHttp.ResponseText
Else
GetHTML = "Incorrect URL"
End if
Else
GetHTML = Err.Description
End If
Set objXMLHttp = Nothing
End Function
' write the results to our page by calling the function above
Response.Write GetHTML("http://www.example.com/amazon/amazon.php?locale="
& locale
& "&mode=" & mode & "&search="
& search & "&associates_id=myid-20&page="
& page & "&dir=" & dir & "")
%>
Note: I entered some hard returns in the Response.Write statement so you wouldn't have to scroll sideways. Everything between Response.Write and "") should be on the same line.
 
If you are wondering why I did this, its because I use site-wide ASP include files, some of them data-driven and I didn't want to rewrite working code.  So I basically wrapped the ASP page around a PHP page, and then modified the PHP page to refer to the ASP page in all the links, instead of the PHP page.
 
In this example, I was not concerned with whether or not someone found the PHP script.  It would basically serve the same content regardless, it would just be missing the header and footer of my website.
 
PHP has a similar function that can be used to include HTML (including ASP) pages.  The PHP function, is much shorter, if I remember correctly.
 
Although I haven't tried this, you may be able to check who is calling the script and deny access if its not coming from the embedded page.  You could probably do this by checking the referrer.
 
I know that when I embedded an ASP include in an ASP.NET page, the referred was listed as the calling page.  It may be the same with PHP and ASP.  If so, you can check to see if the referrer matches the page that the script is supposed to be embedded in, and refuse to run if called directly or from any other page.
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.