New to PHP - please help

Discussion in 'HTML & Website Design' started by David-D, Feb 8, 2007.

  1. #1
    I've downloaded a free imageresizer script. All i really need to do is use the following code to active it:
    <?php
    include("ImageEditor.php");
    $imageEditor = new ImageEditor("imagename.jpg", "imagelocation");
    $imageEditor->resize(x, y);
    $imageEditor->outputImage();
    ?>

    Now, i want to link to this script with text from a html file.
    Like when you click: "Resize to 50x50" it'll start the script. However, i want the php script to get the image name from the html file, to avoid creating multiple php scripts. Since i will be having alot of pictures placed in different locations that will need the resize option.

    Also, if you have a smarter way of doing this, please let me know...
     
    David-D, Feb 8, 2007 IP
  2. aditya_sfs

    aditya_sfs Peon

    Messages:
    2,271
    Likes Received:
    389
    Best Answers:
    0
    Trophy Points:
    0
    #2
    okay do it like

    <?php
    $image=$_REQUEST['image'];

    include("ImageEditor.php");
    $imageEditor = new ImageEditor($image, "imagelocation");
    $imageEditor->resize(x, y);
    $imageEditor->outputImage();
    ?>

    Now say the script name is resize.php
    You can access it from resize.php?image=xxx.jpg
    the xxx.jpg will be retrieved and stored in the $image variable and passed on to the function.

    In the HTML, below the image you can link the same way to resize.php?image=filename.jpg

    ;)
    aditya
     
    aditya_sfs, Feb 8, 2007 IP
  3. technoguy

    technoguy Notable Member

    Messages:
    4,369
    Likes Received:
    306
    Best Answers:
    0
    Trophy Points:
    205
    #3
    
    <a href=page.php?id=clicked>Resize to 50x50</a>
    
    PHP:
    on the same page at the top put this code

    
    <?php
    if(isset($_GET['id']))
    {
    
    Paste your imageeditor code here.
    }
    ?>
    
    PHP:
     
    technoguy, Feb 8, 2007 IP
  4. David-D

    David-D Peon

    Messages:
    122
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks!
    That solved my problem :)
     
    David-D, Feb 8, 2007 IP