Print Page | Close Window

Passing variables from ASP to PHP

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=18362
Printed Date: 29 March 2026 at 7:39pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Passing variables from ASP to PHP
Posted By: ctscott
Subject: Passing variables from ASP to PHP
Date Posted: 11 February 2006 at 2:13pm
I have someone who's written his app. in PHP and wants to piggyback onto my site as we have complementing content.   We want to allow access to  registered members only (WWF) plus  I need to pass him Author ID and possibly Name for some logging purposes.  I don't want to give him access to the Author table.
 
On the permissions access part, I had planned on getting him to include a .asp module that would check for being logged in, thinking that the server would run the ASP on the include.  This thread, http://forums.webwiz.net/forum_posts.asp?TID=16187 - http://forums.webwiz.net/forum_posts.asp?TID=16187  , indicates I can't mix and match ASP/PHP, tho I'll have to give it a try and see.  Has anyone tried this?
 
On the variable passing part,  I don't want to use cookies and there won't be a form, just a link, and don't really want to use the querystring but at the moment it seems to be the option of choice.  Does anyone know of another way to pass the Author info.  to the PHP app that's not visible to the nekid eye?
 
Thanks.


-------------
______________________
http://www.cfbtrivia.com" rel="nofollow - College Football Trivia



Replies:
Posted By: MadDog
Date Posted: 11 February 2006 at 7:42pm
You can not mix ASP and PHP code.

The only way to pass variables would be to put them in a Cookie, Session, or QueryString.


-------------
http://www.iportalx.net" rel="nofollow">


Posted By: ub3rl337ch3ch
Date Posted: 13 February 2006 at 10:18pm
couldn't you use a posted field too? not just one that sends to querystring?
 
anyway, you could have a hidden form (display:none) and put all the necessary data in there with .asp, then use an onclick event with the 'link' to post the form... obviously the form would have the 'action' of wherever the link is supposed to go... then just harvest the posted data with php on the other end...
 
or you could just rewrite ur friend's app... LOLWink


Posted By: ctscott
Date Posted: 17 February 2006 at 4:05pm
i've about ruled out Session as an option as i've haven't figured out a way for the two to talk using Session variables.  looks like i'm down to querystrings and cookies.

-------------
______________________
http://www.cfbtrivia.com" rel="nofollow - College Football Trivia


Posted By: WebWiz-Bruce
Date Posted: 17 February 2006 at 4:16pm
If you are using querystring, cookies, HTML form (even post), then you should be very careful of security as all these methods can be altered quite easily by a hacker.

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: ctscott
Date Posted: 17 February 2006 at 8:46pm
Originally posted by -boRg- -boRg- wrote:

If you are using querystring, cookies, HTML form (even post), then you should be very careful of security as all these methods can be altered quite easily by a hacker.
 
agreed, but  unfortunately it looks like i'm running out of options. 
 
i may can come up with some compatible FSO type function or something or possibly passing the author_id via a querystring to a php script via a blured form with javascript.... still experimenting.
 
feels like i'm the only one on the planet determined to do this.


-------------
______________________
http://www.cfbtrivia.com" rel="nofollow - College Football Trivia


Posted By: ub3rl337ch3ch
Date Posted: 19 February 2006 at 9:49pm
so asp and php use different sessions?


Posted By: dpyers
Date Posted: 20 February 2006 at 12:05am
Asp and php can use the same session, they just use different interpreters.

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: ctscott
Date 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.



-------------
______________________
http://www.cfbtrivia.com" rel="nofollow - College Football Trivia


Posted By: wistex
Date 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.


-------------
http://www.wistex.com" rel="nofollow - WisTex Solutions
http://www.caribbeanchoice.com/forums" rel="nofollow - CaribbeanChoice Forums



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net