FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » error while call php function in javascript?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
error while call php function in javascript? [message #173877] Wed, 11 May 2011 12:10 Go to previous message
Amit Prakash Pawar is currently offline  Amit Prakash Pawar
Messages: 10
Registered: October 2010
Karma:
Junior Member
function encrypt_url($string)
{
	$key = "1AT2#mr(luv^iU3tp>";
	$result = '';
	for($i=0; $i<strlen($string); $i++)
	{
		$char = substr($string, $i, 1);
		$keychar = substr($key, ($i % strlen($key))-1, 1);
		$char = chr(ord($char)+ord($keychar));
		$result.=$char;
	}
	return urlencode(base64_encode($result));
}


$data=encrypt_url('http://www.test.com');
Normally through PHP code i got encrypted value ->
pqW1xGxSnOmf46Pqw9zJYdffqw%3D%3D

When i try through javascript getting some wrong output

// Javascript
var my_url=document.getElementById('url').value;

// my_url='http://www.test.com';

var final_post_url=<?=encrypt_url(my_url)?>;
alert(final_post_url);

how to get correct encrypted data through java script?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PHP Document
Next Topic: php unit test framework suggestions
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 14:42:28 GMT 2024

Total time taken to generate the page: 0.04707 seconds