Including php files without using php
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 posted this at 18:40 — 27th May 2006.
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:
<script language="JavaScript">
test
</script>
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\"] \";
?>
-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.