Help - Search - Members - Calendar
Full Version: Looking For 2 Things
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
MrTouz
Hello,

Almost done with my script i need to find 2 more things, either to DL or a tutorial to remake... does not really matter to me. I just can't find them or not searching hard enough... im working to hard on it that ive lost senses...

Profile picture :

I have my database set for my users info, i just need them to have ONE profile picture. I need to be able to set the size (or not does not really matter... but its always better) but set the format (only jpg bmp png....) and not allow cetain formats such as exe files and stuff like that. The script needs to be able to replace pictures n case the user changes his pics. And better... delete the old one (so my server does not get crowed by morons who love to change their profile pictures)

(my other thought was to make them upload their pic on their server and just set up a link <input> box so it shows what ever they have set... less problems as well) still not sure about that !

Message system :

Ok this is the one i am really lost... i dunno where to start, what to look for... or even how to do it. I would like to have a system where users can have a message system. Not a WYSIWYG coz i can add that later on but more over a page where i can send messages and receive some.

Sendmess.php ?

To : (profile name input)
Subject : (subject input)
Content : (textarea for its content)


Receivemess.php ?

Once sent, the user gets the message on his inbox like

date | from sender | title | (select box used for delet) (when i think about it... basically like zymics tongue.gif

___

But nothing to fancy... i don't really care if there is a Read unread... i just want a limit of 10 messages. And the field not to accept more than 1000 caracters.

Anyone can help ? knows where to find that type of things ?

Thanks biggrin.gif
uncled1023
um, i have a message system tutorial in the tutorials section, and for the profile picture, i have one set up, and ill put it into tutorial format for you.
MrTouz
Wow thanks a lot ! going to look right now !
MrTouz
Sorry, i am bumping this lady.

Thanks uncled for this awesome PM system which i integrated PERFECTLY into my system...

But i need 'still' a avatar system.

Now that i see the Message system, i think i can write my own but should i use the same path ?

create a table called 'avatars'
username (primary)
avatar (image name and extension)
change (number of how many times they changed it tongue.gif just coz i want to try the adding data +1 again:P)

Should i start that way ?
uncled1023
yea, i have my avatar in my users table though to help make it easier to attribute to their account.
MrTouz
That's what i have now. I have a row called avatar. I was thinking on integrating the data like that.
Im still having issues with the uploads.

My problem is that if someone changes his avatar than the old one is still on my server. Which pisses me off since if everybody changes their avatar all the time... i am one screwed mother fucker. Ill end up with 10 000 avatars for 1000 members :/ that sucks.

I need a script that replaces the image (deletes the old one) when a new one is set up.
flyboy
Hmm well the only way that i would suggest is somehow have the image name be the exact name as the previous avatar image. That way it will replace the old one. How you go about doing that i do not know.

Are you tryn to work with a cms or using your own system built from scratch.
MrTouz
Its my own system from scratch. I believe i can set it so the name is the session's username. No sure about that but i think i can do it. The only problem i see is uppercase names and lower case names :/

I have to try that. You gave me one more option.

Thank you flyboy
Ed
Providing the directory has execute permissions, just use http://www.php.net/unlink

Remove the existing file, move the new one into location, update the db column. Perhaps use the user index as the unique identifier for the image, so the user index prefixed to the file extension (so it renders correctly).
uncled1023
Heres the code i use to upload a pic and save it to the database under Seal (aka avatar)

this is for both posting a url to the pic, and uploading your own. the form is as follows.

CODE
<form enctype="multipart/form-data" action="upload.php" method="POST">
            <!-- MAX_FILE_SIZE must precede the file input field -->
            <input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
            <!-- Name of input element determines name in $_FILES array -->
            Upload Avatar:
            <input name="file" type="file" id="file" />
            <input type="radio" name="upload" value="file"><br />
            <br />
            Use URL:
            <input name="text" type="url" id="url" />
            <input type="radio" name="upload" value="url"><br />
            <br />
            <input type="submit" value="Upload" />
          </form>


aand here is the upload.php

CODE
<?php

require 'db_connect.php';

$upload = $_POST['upload'];

//check if they are using a url.

if($upload == 'url') {
    
    $sql = "UPDATE users SET url_seal='1', seal='".$_POST['url']."' WHERE governor_name='".$_SESSION['username']."'";

    $query=mysql_query($sql);

    
} else {

//they are uploading a file.

    $seal_name = $now.'_'.$_FILES[file]['name'];

//this is the target directory where your saving the file

    $target_path = "seals/";

    $target_path = $target_path . $seal_name;

    if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
    
        $user = $_SESSION['username'];

        $sql = "UPDATE users SET url_seal='0', seal='$seal_name' WHERE governor_name='".$_SESSION['username']."'";

        $query=mysql_query($sql);
    
    ?>
    
            &lt;script type="text/javascript">
        <!--
        window.location = "/index.php?id=edit_account&art=<?php echo $_SESSION['username'];?>"
        //-->
        </script>
    
    <?php
    
    } else{
     ?>
    
            &lt;script type="text/javascript">
        <!--
        window.location = "/index.php?id=edit_account&art=<?php echo $_SESSION['username'];?>&error=5"
        //-->
        </script>
    
    <?php
    }
}
?>
MrTouz
Thanks a lot.

I am not at home now, once i am back i will try that.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.