becca800 Posted October 25, 2007 Share Posted October 25, 2007 I have a PHP script that I am trying to include in asp. Most people say you can not do this but actually you can by using this include: <% Dim objHttp set objHttp = Server.CreateObject("Microsoft.XMLHTTP") objHttp.open "POST", "http://www.yoursite.com/ad/comments/comments.php", false objHttp.Send If objHttp.status = 200 Then response.write(objHttp.responseText) End If set objHttp = nothing %> I found this code and it works great. However, the script calls for one the url variable to be assessed by using the function: <input type=hidden name="href" value="{$_SERVER['REQUEST_URI']}"> Instead of getting the correct url of the asp page in which it is inserted, it records the url from the insert: http://www.yoursite.com/ad/comments/comments.php I have done tests by inserting this into test php files, and of course, it works fine, so it is the insert method I am using above which is giving it trouble. I am not a php expert, I know very little, I only know basic html so if you have any thouhts you might need to literally draw it out for me. I found one post in another forum which was similar and someone said that the person needed to add get variables but I didn't know what this meant. Thank, Becca Quote Link to comment https://forums.phpfreaks.com/topic/74756-solved-php-insert-in-asp-using-microsoftxmlhttp/ Share on other sites More sharing options...
MadTechie Posted October 25, 2007 Share Posted October 25, 2007 Okay i have read this twice.. and i have no idea what your asking.. what do you want to do ? Quote Link to comment https://forums.phpfreaks.com/topic/74756-solved-php-insert-in-asp-using-microsoftxmlhttp/#findComment-377901 Share on other sites More sharing options...
becca800 Posted October 25, 2007 Author Share Posted October 25, 2007 Okay, let's see if I can word this better. I am inserting a php script into an asp page using the insert above as shown, this is the only way it will run. The script fills out a form and includes the url. It obtains the url with the single line function described above. However, it is not getting the correct url. It is getting the url from the php page which I am inserting, rather than the new asp page which it is inserted into. It has to do with the way I am inserting it. There should be a way to correct this, I would think. Make sense? Forgive me, I am no a php expert and my techie lingo sucks. Quote Link to comment https://forums.phpfreaks.com/topic/74756-solved-php-insert-in-asp-using-microsoftxmlhttp/#findComment-377909 Share on other sites More sharing options...
MadTechie Posted October 25, 2007 Share Posted October 25, 2007 Okay i think i get you.. your calling from an ASP using XMLHTTP request to call a PHP page (to do stuff) but a form on the PHP page needs to contain the path of the ASP page .. Okay.. if you doing 90% of the code in ASP i would do this <% Dim objHttp set objHttp = Server.CreateObject("Microsoft.XMLHTTP") 'Get the current page (i thin the below will do it set Thispage ="http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") 'Pass it via URL objHttp.open "POST", "http://www.yoursite.com/ad/comments/comments.php?PAGE=" & Thispage, false objHttp.Send If objHttp.status = 200 Then response.write(objHttp.responseText) End If set objHttp = nothing %> $ASPpage = urldecode($_GET['PAGE']); <input type=hidden name="href" value="$ASPpage"> Other option is PHP only <input type=hidden name="href" value="{$_SERVER['HTTP_REFERER']}"> Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted. i think thats what your looking for Quote Link to comment https://forums.phpfreaks.com/topic/74756-solved-php-insert-in-asp-using-microsoftxmlhttp/#findComment-377928 Share on other sites More sharing options...
becca800 Posted October 25, 2007 Author Share Posted October 25, 2007 i am trying this but i have a question. i removed your comments and used: <% Dim objHttp set objHttp = Server.CreateObject("Microsoft.XMLHTTP") Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") objHttp.open "POST", "http://www.advicediva.com.com/ad/comments/comments.php?PAGE=" & Thispage, false objHttp.Send If objHttp.status = 200 Then response.write(objHttp.responseText) End If set objHttp = nothing %> is this correct? Again, I am very poor with this. Should I have put the actual www.address in the ? and thispage? Right now, the way it is it turns me to a completely new url. Quote Link to comment https://forums.phpfreaks.com/topic/74756-solved-php-insert-in-asp-using-microsoftxmlhttp/#findComment-377943 Share on other sites More sharing options...
MadTechie Posted October 25, 2007 Share Posted October 25, 2007 you need the Thispage = i added that back bascially you could do Thispage="www.thisISmySITE.com" but Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") gets those details try it, see what happens <% Dim objHttp set objHttp = Server.CreateObject("Microsoft.XMLHTTP") Thispage=Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") objHttp.open "POST", "http://www.advicediva.com.com/ad/comments/comments.php?PAGE=" & Thispage, false objHttp.Send If objHttp.status = 200 Then response.write(objHttp.responseText) End If set objHttp = nothing %> Quote Link to comment https://forums.phpfreaks.com/topic/74756-solved-php-insert-in-asp-using-microsoftxmlhttp/#findComment-377951 Share on other sites More sharing options...
becca800 Posted October 25, 2007 Author Share Posted October 25, 2007 THANK YOU! That did the trick. I removed this part: Request.ServerVariables("SERVER_NAME") because it was giving me a double url. ANd it worked great. You rock MadTechie! Quote Link to comment https://forums.phpfreaks.com/topic/74756-solved-php-insert-in-asp-using-microsoftxmlhttp/#findComment-377970 Share on other sites More sharing options...
MadTechie Posted October 25, 2007 Share Posted October 25, 2007 your welcome Quote Link to comment https://forums.phpfreaks.com/topic/74756-solved-php-insert-in-asp-using-microsoftxmlhttp/#findComment-377972 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.