Follow us on Twitter!
One mans freedom fighter, another's terrorist.
Thursday, April 17, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 17
Guests Online: 17
Members Online: 0

Registered Members: 82815
Newest Member: medjiking
Latest Articles
View Thread

HellBound Hackers | Computer General | Webmasters Lounge

Author

PHP javascript link onclick


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 30-07-07 00:14
Heyy guys ...
I need a piece of php script to be exicuted when a link is clicked on...


e.g.

<a onclick="phpstuff()">delete Item</a>


Author

RE: PHP javascript link onclick


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 30-07-07 00:20
You can't, PHP is ran on the server, not the client. However, if you use AJAX you can do what you need.
Author

RE: PHP javascript link onclick


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 30-07-07 00:21
are you suree?? ive seen it done .... im sure ..
Hmm k ... i suppose ill just use php Get or something


Author

RE: PHP javascript link onclick


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 30-07-07 00:22
you could make that jscript load a new page with the php....
what are you trying todo?


Author

RE: PHP javascript link onclick


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 30-07-07 00:43
Code

<script>
function phpstuff(){
  <?php
  echo "my php stuff<br />\n";
  ?>
}
</script>

<a onclick="phpstuff()">delete Item</a>





Edited by on 30-07-07 00:44
Author

RE: PHP javascript link onclick


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 30-07-07 00:50
dw .. thanks guys i done it like this :

viewer.php

Code
Blah Blah....
  <a href=deleteitem.php?id=$id>Delete Item</a><br> 
  <br></b></font>
        ");
   }
?>
</center>




then deleteitem.php

Code
<?
require "config.php";
   database_connect();
    $id = $_GET['id'];
   $sql = "DELETE FROM contact
            WHERE id = '$id'";
   $query = mysql_query($sql)or die("There was a problem while deleting: ". mysql_error());    
?>




sawted


Author

RE: PHP javascript link onclick


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 30-07-07 00:50
xJorDyx wrote:
Code

<script>
function phpstuff(){
  <?php
  echo "my php stuff<br />\n";
  ?>
}
</script>

<a onclick="phpstuff()">delete Item</a>




The problem is, is that the code will be executed even before the link is clicked. Not a very good idea.
Author

RE: PHP javascript link onclick


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 30-07-07 00:53
i think what you want is:

Code

<script>
function phpstuff()
{
window.location="thephp.php";
}
</script>




and have the thephp.php redirect back to your page
but really, i would do it with $_GET....works mo betta