SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    398
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php embed code generator

    so what im tryin to do is have someone enter the url of a video, and have it make an embed code, which they can copy and paste somewhere like myspace. so heres teh code i got


    <?php
    $vid = $_POST['vid'];
    if(isset($vid)) {
    echo "<textarea><embed src=\"$vid\"></textarea>";
    } else {
    ?>
    <form action="form.php" method="post">
    <input type="text" size="20">
    <input type="submit" value="submit">
    </form>
    <?php
    }
    ?>

    naming the file "form.php" i have no idea why this shouldnt work. but whenever i click submit, it just clears the form.

    any ideas

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you forgot to name your text field.

  3. #3
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    398
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, it worked.... heres another problem im having with this code, which generates an img code
    PHP Code:
        <?php
    $vid 
    $_POST['vid'];
    $link $_POST['link'];
    if(isset(
    $vid)) {

    echo 
    '<p>';
    echo 
    '<p><span class="style1"><strong>Copy and paste this code</strong></span></p>';
    echo 
    "<textarea cols='60' rows='4' readonly='true'><a href='$link'><img src=\"$vid\" width='500' border='0'></a></textarea>";
    echo 
    '</p>';
    echo 
    '<p>';
    echo 
    '<p><span class="style1"><strong>Preview</strong></span></p><BR>';
    echo 
    "<a href='$link'><img src=\"$vid\" width='500' border='0'></a>";
    echo 
    '</p>';
    } else {
    ?>
      </p>
      <p><span class="style1">
      Image Url</span> <BR>
        <form action="form2.php" method="post">
        <input type="text" size="60" name="vid">
        </p>
    </p>
      <p><BR>
        <span class="style1">
        If you would like the image to link to a website when clicked <BR> 
        Enter website url here</span> <BR><input type="text" size="60" name="link">
    <BR>
    <input type="submit" value="submit">
    </p>
    <?php
    }
    ?>
    what im trying to do is set the max width to 500, but what i cant figure out, is how to make it so that if the image is smaller than 500, it keeps its size

    any ideas, thanks

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    see getimagesize()

    then you can use an if/else statement to handle what to do if the image is less than, or greater than 500


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •