Execute script based on the parameter passed with the URL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ajm113
    New Member
    • Jun 2007
    • 161

    #1

    Execute script based on the parameter passed with the URL

    How do I have it so if a word in the url was entered then php will run a part of a script?

    Example: Since I want to save server space I want to be able to update my database in one file. Which means deleting, updating, and adding data. So I want to trying to keep everything in one file. So if the user lets say wanted to delete something it will go through the update.php page. But after the ".php" it will show something like "delete" and then php will run a part of the script set up for it and delete what ever the user wanted to delete in mysql,
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    You can use a parameter named 'action' and passed the appropriate action value. e.g.

    [PHP]if($_GET["action"]="edit")
    {
    // edit procedure
    }
    elseif($_GET["action"]="delete")
    {
    // procedure to delete
    }[/PHP]

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      Thread title changed – Ajaxrand
      [please read why]

      Earlier: How do I have it so if a word in the url was entered then php will run...
      Recent: Execute script based on the parameter passed with the URL

      Comment

      • kovik
        Recognized Expert Top Contributor
        • Jun 2007
        • 1044

        #4
        Use a query string (page.php?delet e).

        Comment

        Working...