Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    38
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Exclamation Need help with basic PHP script

    Hi, I'm making a simple image upload site but I know very little PHP coding and was wondering whether any of you guys could help.

    If you take a look at this link hopefully you'll be able to see what I'm trying to do closer, http://swiftsnap.skiroid.com/.

    It all works well expect for I want the green or red notification box to replace the blue one instead of appearing underneath it.

    Here is the code I've got at the moment. If you need to change the structure altogether please do.

    PHP Code:
    <?php
        
    echo "
        <div id='notification-ok'>
            <div id='notification-image'>
                <img src='images/ok.png' width='100' height='100' />
            </div>
            <p id='notification-title'><strong>Pick your image to share.</strong></p>
            <p>Swift Snap offers you a quick and easy service. All you have to do is choose an image you'd like to upload and you'll have the link to share it within seconds!</p>
        </div>
        "
    ;
        if (
    $_POST['uploadbutton']) {
            
    $name $_FILES['picture']['name'];
            
    $type $_FILES['picture']['type'];
            
    $tmpname $_FILES['picture']['tmp_name'];
            
    $charset 'abcdefghijklmnopqrstuvwxyz0123456789';
            
    $length 15;
            
    $ext substr($namestrrpos($name'.'));
            if (
    strstr($type"image")) {
                for (
    $i 0$i <= $length$i++) {
                    
    $rand rand() % strlen($charset);
                    
    $tmp substr($charset$rand1);
                    
    $code .= $tmp;
                }
                while (
    $numrows != 0) {
                    for (
    $i 0$i <= $length$i++) {
                        
    $rand rand() % strlen($charset);
                        
    $tmp substr($charset$rand1);
                        
    $code .= $tmp;
                    }
                }
                
    move_uploaded_file($tmpname"pictures/".$code.$ext);
                echo 
    "
                <div id='notification-yes'>
                    <div id='notification-image'>
                        <img src='images/yes.png' width='100' height='100' />
                    </div>
                    <p id='notification-title'><strong>Your image is ready to share!</strong></p>
                    <p>Your image has been uploaded to:<br><a href='http://swiftsnap.skiroid.com/pictures/$code$ext' target='_blank'>swiftsnap.skiroid.com/pictures/$code$ext</a></p>
                </div>
                "
    ;
            }
            else
                echo 
    "
                <div id='notification-no'>
                    <div id='notification-image'>
                        <img src='images/no.png' width='100' height='100' />
                    </div>
                    <p id='notification-title'><strong>Unable to upload your file.</strong></p>
                    <p>You have either chosen a file which is not an image or you havn't chosen a file at all. You can only upload images to Swift Snap.</p>
                </div>
                "
    ;
        }
    ?>
    I would appreciate any help. Thanks.
    Last edited by Skiroid; 08-25-2011 at 03:56 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I won't follow links from work.
    Is this what you are talking about?
    PHP Code:
        echo "
        <div id='notification-ok'>
            <div id='notification-image'>
                <img src='images/ok.png' width='100' height='100' />
            </div>
            <p id='notification-title'><strong>Pick your image to share.</strong></p>
            <p>Swift Snap offers you a quick and easy service. All you have to do is choose an image you'd like to upload and you'll have the link to share it within seconds!</p>
        </div>
        "

    ?

    If so, move that to the else of this branch: if ($_POST['uploadbutton']) (which should be if (isset($_POST['uploadbutton']))). Create the else and move that first print into it, then it will only show 1 of those three notification areas.

  • #3
    New Coder
    Join Date
    Aug 2011
    Posts
    38
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Thumbs up

    Quote Originally Posted by Fou-Lu View Post
    I won't follow links from work.
    Is this what you are talking about?
    PHP Code:
        echo "
        <div id='notification-ok'>
            <div id='notification-image'>
                <img src='images/ok.png' width='100' height='100' />
            </div>
            <p id='notification-title'><strong>Pick your image to share.</strong></p>
            <p>Swift Snap offers you a quick and easy service. All you have to do is choose an image you'd like to upload and you'll have the link to share it within seconds!</p>
        </div>
        "

    ?

    If so, move that to the else of this branch: if ($_POST['uploadbutton']) (which should be if (isset($_POST['uploadbutton']))). Create the else and move that first print into it, then it will only show 1 of those three notification areas.
    Got it. Thanks!


  •  

    Posting Permissions

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