Up until now I have done links like this :

<a href='delete.php?file_name=$file_name'>Delete</a>

But can I instead of having an external page ( delete.php ) I want it to be a function, do I do it like this :

$_SERVER['PHP_SELF']

Basically I need to know, how I can click on a link and run a function in the same script.

I want to do this all in one script with functions.

Can someone help me do this ?

Kind regards

    sure.. Just use a GET variable called action to describe what you want to do. Then in the script, use a switch case of if statements to detect what you need to do.

    for example:
    link looks like this:
    index.php?action=delete&id=5

    then in index.php

    
    if($_GET[action] == "delete")
    {
      // do the delete stuff in here
      // edit: you can even include a file here
      // like:
      include(delete.php);
    }
    
    
      Write a Reply...