Web Analytics Made Easy -
StatCounter Need help with basic PHP script - CodingForum

Announcement

Collapse
No announcement yet.

Need help with basic PHP script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Resolved 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; Aug 25, 2011, 10:56 AM.

  • #2
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

    Comment


    • #3
      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!

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎