flex Posted April 27, 2007 Share Posted April 27, 2007 can you help me with this script? I picked it up from a site but it doesn't work. no matter what i do it gives me "not logged in"! This is an avatar script that uploads your avatar and names the avatar "username.gif" but it names it just ".gif" here is the code <?php $host = ""; $db_username = ""; $password = ""; $db_name = ""; $connection = mysql_connect($host, $db_username, $password); mysql_select_db($db_name); $username = $_SESSION['username'] = $_POST['username']; $maxwidth = "50"; // Max width allowed for avatars $maxheight = "50"; // Max height allowed for avatars if (isset($_POST['uploadit'])) { $filetype = $_FILES['userfile']['type']; $filetypex = substr($filetype,0,5); if ($filetypex == image) { $newid = "images/"; $newid .= $username; $newid .= ".gif"; $mysock = getimagesize($_FILES['userfile']['tmp_name']); $imagewidth = $mysock[0]; $imageheight = $mysock[1]; if ($imagewidth <= $maxwidth && $imageheight <= $maxheight) { if(!(copy($_FILES['userfile']['tmp_name'], $newid))) die("Cannot upload files."); { echo "Your New Avatar Has Been Created"; } } else { echo "This avatar is to big, please change it"; } } else { echo "This File Is Not a Image Fool"; } } else { if ($username != null) { $filename = 'images/'.$username.'.gif'; if (file_exists($filename)) { echo '<img src="'.$filename.'" border="0">'; } elseif($username == null) { echo "You Do Not Have An Avatar"; } ?> <form action="<?=$_SERVER['REQUEST_URI'] ?>" method="post" enctype="multipart/form-data"> Select a file <input type="file" name="userfile" size="18"> <br> <input type="submit" value="Upload My Avatar" name="uploadit" size="18"> <br><br> <i>All Files Will Be Converted To .gif <?php } else { echo 'not logged in'; } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.