Jump to content



Recommended Posts

Before onclick  the function call() is calling ?





//LOGGED IN ID VALIDATION - Only registered user Access !
{	header("Location:".$config_basedir."login.php?error=2767");	}

<script type="text/javascript" >
function downloadPdf(el) {     
	var iframe = document.createElement("iframe");     
iframe.src = "download/itil.zip";     
iframe.onload = function() {         
	// iframe has finished loading, download has started        
	 el.innerHTML = "Download";     
iframe.style.display = "none";
function call()
	//get ip address...
	 	// share internet 
		$ip .= "/S";
	 	// pass from proxy
		$ip .= "/P";
	 else {    $ip=$_SERVER['REMOTE_ADDR']; $ip .= "/O";  } 

	$sql = "INSERT INTO downloadUserIP( date, userID, ProductID,IP ) VALUES ( NOW(),'".$_SESSION['SESS_USERID']."','".$a."','".$ip."');";
	$res = mysql_query($sql);
	{ die(" Could not query the database customers 24 : <br/>". mysql_error() ); }
	$_SESSION['SESS_GUEST_IP'] =  mysql_insert_id();

	echo "ok";

<a href="download/ECDL.zip"   onclick="this.innerHTML='<? call(); ?>'; downloadPdf(this);">Download</a>

Link to comment
Share on other sites

Because PHP is serverside, not clientside.  Javascript is clientside.  The only way you can have functionality like this (call a serverside script based on a a clientside (javascript) event occurring) is to implement the serverside functionality in a seperate script that you make an ajax call to using a get or post method.

Link to comment
Share on other sites

voip, please don't report a post because a mod has moved it.


You are not understanding the basics of client-server web programming.  Read carefully:


PHP - PHP is a server-side language that only executes on the SERVER.  It can only run code on your server, and cannot run code on the client.  A PHP page will execute entirely and then die before ANY content is shown to the user.


JavaScript - JavaScript is an entirely separate language.  Read that again.  JavaScript is a programming language that has nothing to do with PHP.  It is interspersed into HTML code for convenience.  It runs on the CLIENT machine.  It cannot run on your server.  Any javascript on your page executes AFTER the PHP is already dead.  JavaScript can trigger FURTHER PHP events, but they do not run in tandem.


Your problem is that you want something to happen when the user clicks.  This can be accomplished in two ways:

1)  Reloading the page entirely by pointing it to a new URL.  This is not what you want, but this is the default behavior for clicking a link.

2)  Trigger the onClick javascript even, in javascript, on the client's machine ONLY.  This has the capacity to call PHP scripts through AJAX, but you must use javascript to perform client-side operations.


Now, given this information, continue the discussion.


And as a side note, for the love of god use complete sentences and real words.  The quality of help you receive is directly proportional to how easy your posts are to read.  See how mine is all spelled correctly and the sentences are complete?



Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.