God Ownz here is the essential parts of the script. i stripped the styling and so out of the site just to give you the core but this is it.
<?php
include("includes/database.php");
$user=$_SESSION['nlemail'];
$pass=$_SESSION['nlpassword'];
$token=$_SESSION['nltoken'];
$query=("select * from useraccounts where email='$user' and password='$pass' and token='$token';");
$results=mysql_query($query);
$userinfo=mysql_fetch_array($results);
$username=$userinfo['username'];
$namesurname=("$userinfo[name] $userinfo[surname]");
$imagename = $userinfo['profilephoto'];
if(isset($_POST['submit'])){ //if(isset($_POST['submit'])){
if (isset ($_FILES['new_image'])){
$today=date("D, jS F Y G:i",time()); // gets today's date
$imagename = ("$username"."_".md5($today).".jpg");
$source = $_FILES['new_image']['tmp_name'];
$target = "gfx/profilephotos/".$imagename;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = "gfx/profilephotos/" . $imagepath; //This is the new file you saving
$file = "gfx/profilephotos/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$largeimage=500; //sets the longest side
$imgratio=$width/$height; //works out the image ratio and if its a portrait or landscape
if ($imgratio>1){ //tests if it is a landscape
$newwidth = $largeimage; //sets the longest side for landscape
$newheight = $largeimage/$imgratio; //calculate the shortest side for landscape
}else{
$newheight = $largeimage; //sets the longest side for Portrait
$newwidth = $largeimage*$imgratio; //calculate the shortest side for Portrait
}
$tn = imagecreatetruecolor($newwidth, $newheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
$save = "gfx/profilephotos/thumb_" . $imagepath; //This is the new thumbnail file you saving
$file = "gfx/profilephotos/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$thumbimage=80;
$imgratio=$width/$height;
if ($imgratio>1){
$newwidth = $thumbimage;
$newheight = $thumbimage/$imgratio;
}else{
$newheight = $thumbimage;
$newwidth = $thumbimage*$imgratio;
}
$tn = imagecreatetruecolor($newwidth, $newheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
$updatepass=("update useraccounts set profilephoto='$imagepath' where email='$user' and password='$pass' and token='$token';");
mysql_query($updatepass);
}
} //if(isset($_POST['submit'])){
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<META NAME="DESCRIPTION" CONTENT="...summary of web page...">
<meta name="keywords" content="" />
<title>title</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body id="HOMEPAGE">
<div id="wrapper">
<div id="header"></div>
<div id="content">
<div id="profile">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
<table width="100%">
<tr>
<td width="2"> </td>
<td colspan="2" align="center" valign="middle"> <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /></td>
</tr>
<tr>
<td width="2"> </td>
<td colspan="2" align="center" valign="middle"><input name="submit" type="submit" value="Upload Image" /></td>
</tr>
<tr>
<td width="2"> </td>
<td colspan="2" align="center" valign="middle"><?php echo "Large image: <br><img src='gfx/profilephotos/".$imagename."'><br>"; ?></td>
</tr>
<tr>
<td width="2"> </td>
<td colspan="2" align="center" valign="middle"><?php echo "Thumbnail: <br><img src='gfx/profilephotos/thumb_".$imagename."'>"; ?></td>
</tr>
</table>
</form>
</div>
</div>
<div id="sidebar"></div>
<div id="clear"> </div>
<div id="footer"></div>
</div>
</body>
</html>