Including php files without using php

popinsiteads's picture

He has: 51 posts

Joined: Sep 2005

Hi, I want to be able to provide my users with a code to place on their website which includes a file from my server. I do not want to use php as they may not all have it

I have used but that only worked in mozilla. I want to use javascript maybe. I haven't used javascript before but I have been 'playing around' with this code but still can not get nothing:

<script language="JavaScript" src=http://mysitw/showad.php?user=tester></script>'
In showad.php - I have

<?php
$user
= @$HTTP_GET_VARS[\"user\"]; test
?>

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

Lets analize what you have done here.

The client's website is telling the browser to include javascript from the location:
http://mysitw/showad.php?user=tester (you should wrap that with quotes by the way)

The client's browser calles that URL. Your served executes the code and sets the variable $user to be whatever you have after user=. Inside the PHP tags, it does not output anything to the browser. All the browser gets from the call is the single line containing the word test

In the end, it is the same as having the original code in the client's webpage being:

&lt;script language="JavaScript"&gt;
  test
&lt;/script&gt;
'
As you can see, does nothing effective.

Now, if you want something effective, you could do something such as the following for the php file:

<?php
 
// NOTE: probably should put code here to set the
  //       content type to whatever a javascript file would
  //       normally give to a browser, I don't know it
  //       ofhand.



var userName;
userName = \"= @$HTTP_GET_VARS[\"user\"] \";
?>
(continue regular javascript here...)

-Greg

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.