Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Removing text in HTML with PHP - Help Please

  1. #1
    Join Date
    Aug 2008
    Location
    Smiths, AL
    Posts
    164
    Thanks
    30
    Thanked 5 Times in 5 Posts

    Default Removing text in HTML with PHP - Help Please

    I have a PHP page that has a script for uploading an image in it. After the script is a form that allows you to select and upload an image. Just before the form I have some text that I just wrote in stating some rules. What I want to do is remove the text when the submit button is clicked.

    After the image uploads it shows a clickable preview of the image and some text telling you that your image was added to the DB. But it still shows the actual content text. Can anyone help me with some code to remove it after uploading an image?

    Joe

  2. #2
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    Can we see your existing code?

  3. #3
    Join Date
    Aug 2008
    Location
    Smiths, AL
    Posts
    164
    Thanks
    30
    Thanked 5 Times in 5 Posts

    Default

    Sure here is what I have now...


    PHP Code:
    <?php

    define 
    ("MAX_SIZE","204800");
    define ("WIDTH","720");
    define ("HEIGHT","720");

    function 
    make_thumb($img_name,$filename,$new_w,$new_h)
    {
    $ext=getExtension($img_name);
    if(!
    strcmp("jpg",$ext) || !strcmp("jpeg",$ext))
    $src_img=imagecreatefromjpeg($img_name);

    if(!
    strcmp("png",$ext))
    $src_img=imagecreatefrompng($img_name);

    $old_x=imageSX($src_img);
    $old_y=imageSY($src_img);

    $ratio1=$old_x/$new_w;
    $ratio2=$old_y/$new_h;
    if(
    $ratio1>$ratio2) {
    $thumb_w=$new_w;
    $thumb_h=$old_y/$ratio1;
    }
    else {
    $thumb_h=$new_h;
    $thumb_w=$old_x/$ratio2;
    }

    $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);

    imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);

    if(!
    strcmp("png",$ext))
    imagepng($dst_img,$filename);
    else
    imagejpeg($dst_img,$filename);

    imagedestroy($dst_img);
    imagedestroy($src_img);
    }

    function 
    getExtension($str) {
    $i strrpos($str,".");
    if (!
    $i) { return ""; }
    $l strlen($str) - $i;
    $ext substr($str,$i+1,$l);
    return 
    $ext;
    }

    $errors=0;
    if(isset(
    $_POST['Submit']))
    {
    $image=$_FILES['image']['name'];
    if (
    $image)
    {
    $filename stripslashes($_FILES['image']['name']);

    $extension getExtension($filename);
    $extension strtolower($extension);
    if ((
    $extension != "jpg") && ($extension != "jpeg") && ($extension != "png"))
    {
    echo 
    '<h1>Unknown extension!</h1>';
    $errors=1;
    }
    else
    {
    $size=getimagesize($_FILES['image']['tmp_name']);
    $sizekb=filesize($_FILES['image']['tmp_name']);

    if (
    $sizekb MAX_SIZE*1024)
    {
    echo 
    '<h1>You have exceeded the size limit!</h1>';
    $errors=1;
    }

    $image_name=time().'.'.$extension;
    $newname="xxxxx/xxxx/xxxx/x/xxx/".$image_name;
    $copied copy($_FILES['image']['tmp_name'], $newname);
    if (!
    $copied)
    {
    echo 
    '<h1>Copy unsuccessfull!</h1>';
    $errors=1;
    }
    else
    {
    $thumb_name='xxxxx/xxxx/xxxx/x/xxx/'.$image_name;
    $thumb=make_thumb($newname,$thumb_name,160,120);
    }} }}

    if(isset(
    $_POST['Submit']) && !$errors)
    {

    echo 
    "<center><h2>Your image has been submitted and will be reviewed by our administrators for approval</h2></center>";
    echo 
    '<a href="'.$newname.'"rel="lightbox" title="<strong>Your Submission Image</strong>"> <img src="'.$thumb_name.'"></a>';
    }

    ?>
    HTML Code:
     <p>So you are thinking about uploading an image to our database and have it featured on our homepage. Please read and understand rules before uploading an image. </p>
     <p><strong>RULES:</strong><br>
       1. File format must be JPG, JPEG, PNG.<br>
       2. Files may not be any larger than 200 KB (204,800 bytes).<br>
       3. Images are  at least 160 pixels, and no more than 720 pixels on each side.<br>
       4. You are willing to display your image on our site and understand that anything uploaded to the internet could be stolen </p>
     <form name="newad" method="post" enctype="multipart/form-data" action="" onSubmit="submitonce(this)">
       <input name="understand" type="checkbox" id="understand" value="checkbox">
        
    I have read and understood the rules.(*required)<br>
    
    <table>
    <tr><td><input type="file" name="image" ></td></tr>
    <tr><td><input name="Submit" type="submit" value="Upload Image"></td></tr>
    </table>
    </form>

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I'm using javascript because thats the only way, change:
    Code:
     <p>So you are thinking about uploading an image to our database and have it featured on our homepage. Please read and understand rules before uploading an image. </p>
     <p><strong>RULES:</strong><br>
       1. File format must be JPG, JPEG, PNG.<br>
       2. Files may not be any larger than 200 KB (204,800 bytes).<br>
       3. Images are  at least 160 pixels, and no more than 720 pixels on each side.<br>
       4. You are willing to display your image on our site and understand that anything uploaded to the internet could be stolen </p>
     <form name="newad" method="post" enctype="multipart/form-data" action="" onSubmit="submitonce(this)">
       <input name="understand" type="checkbox" id="understand" value="checkbox">
        
    I have read and understood the rules.(*required)<br>
    
    <table>
    <tr><td><input type="file" name="image" ></td></tr>
    <tr><td><input name="Submit" type="submit" value="Upload Image"></td></tr>
    </table>
    </form>
    To this:
    Code:
    <div id="rules"> <p>So you are thinking about uploading an image to our database and have it featured on our homepage. Please read and understand rules before uploading an image. </p>
     <p><strong>RULES:</strong><br>
       1. File format must be JPG, JPEG, PNG.<br>
       2. Files may not be any larger than 200 KB (204,800 bytes).<br>
       3. Images are  at least 160 pixels, and no more than 720 pixels on each side.<br>
       4. You are willing to display your image on our site and understand that anything uploaded to the internet could be stolen </p></div>
     <form name="newad" method="post" enctype="multipart/form-data" action="" onSubmit="submitonce(this);document.getElementById('rules').style.display='none';">
       <input name="understand" type="checkbox" id="understand" value="checkbox">
        
    I have read and understood the rules.(*required)<br>
    
    <table>
    <tr><td><input type="file" name="image" ></td></tr>
    <tr><td><input name="Submit" type="submit" value="Upload Image"></td></tr>
    </table>
    </form>
    Jeremy | jfein.net

  5. #5
    Join Date
    Aug 2008
    Location
    Smiths, AL
    Posts
    164
    Thanks
    30
    Thanked 5 Times in 5 Posts

    Default

    okay I have it in there but now it's not showing the initial text to begin with. Not sure if it matters or not but just to clarify what all I have going on...
    I have multiple pages here...

    upload_image_data.php (holds all the code and form listed in this thread)
    image_upload.php - Actual viewable page from site calling for "upload_image_data.php"


    Also I have never posted in these threads before so excuse me for being stupid but to make sure I'm doing it right I add my <script></script> tags before and after the <div></div> tags right?

  6. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Can I see a link to your page. Also theres probably something in or on your page thats making the whole thing not display. So I wanna check it out.
    Jeremy | jfein.net

  7. #7
    Join Date
    Aug 2008
    Location
    Smiths, AL
    Posts
    164
    Thanks
    30
    Thanked 5 Times in 5 Posts

    Default

    Sure here you go

    Link to upload page

  8. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Gimme a few minutes.
    Edit: Its not displaying because you have <script> tags around it.
    Find:
    Code:
    <script>
    <div id="rules"> <p>So you are thinking about uploading an image to our database and have it featured on our homepage. Please read and understand rules before uploading an image. </p>
     <p><strong>RULES:</strong><br>
       1. File format must be JPG, JPEG, PNG.<br>
       2. Files may not be any larger than 200 KB (204,800 bytes).<br>
       3. Images are  at least 160 pixels, and no more than 720 pixels on each side.<br>
       4. You are willing to display your image on our site and understand that anything uploaded to the internet could be stolen </p></div></script>
    And change it to:
    Code:
    <div id="rules"> <p>So you are thinking about uploading an image to our database and have it featured on our homepage. Please read and understand rules before uploading an image. </p>
     <p><strong>RULES:</strong><br>
       1. File format must be JPG, JPEG, PNG.<br>
       2. Files may not be any larger than 200 KB (204,800 bytes).<br>
       3. Images are at least 160 pixels, and no more than 720 pixels on each side.<br>
       4. You are willing to display your image on our site and understand that anything uploaded to the internet could be stolen </p></div>
    Jeremy | jfein.net

  9. The Following User Says Thank You to Nile For This Useful Post:

    Dirt_Diver (08-12-2008)

  10. #9
    Join Date
    Aug 2008
    Location
    Smiths, AL
    Posts
    164
    Thanks
    30
    Thanked 5 Times in 5 Posts

    Default

    hey no problem at all. Do you use yahooIM?

  11. #10
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Sure whats your IM, also check my updated post.
    Jeremy | jfein.net

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
  •