Building a Javascript query in php with MD5()

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
laurus
Forum Newbie
Posts: 3
Joined: Mon Sep 05, 2005 8:52 pm
Contact:

Building a Javascript query in php with MD5()

Post by laurus »

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Hi I am building a javascript function in php. It is going swimmingly until I get to the part where I try to use the JS variable 'file' in the MD5() function..
the 'file' var works fine in the section of the code without the MD5().

Code: Select all

 
<?php 
    echo  "<SCRIPT LANGUAGE=\"Javascript\">\n";
    echo  " <!--\n";
    echo  "     function bg(file)\n";
    echo  "     {\n";  
    echo  'window.location = "http://bitcast-g.bitgravity.com/suze/members/files/area3/members/VIDEOS/" + file + "?e='.$t.'&h='.MD5("xxxxxxxxx/suze/members/files/area3/members/VIDEOS/' + file + '?e=".$t).'   "';
    echo  "     }\n";
    echo  "     //-->\n";
    echo  " </SCRIPT>\n";
?>  
 

Code: Select all

<A href="javascript&#058;void()" onClick="bg('2000_3475_1000.wmv');return true">Link</A>

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Building a Javascript query in php with MD5()

Post by pickle »

This Javascript won't be run until PHP has completed & sent the output to the browser. Consequently, the Javascript 'file' variable won't be set until the function is called in the browser - way after PHP (and the md5() function) have finished running.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply