That is useful information and I appreciate it! But I am going to keep all the pages available to everyone even if they did not register. I am going to have a monthly give away to the user who uploads the best pictures so they have to be registered to be eligible. But I don't want to discourage people from uploading either by making them go through the registration process if they don't want. Can you tell me how I can display the users name at the top of every page when you are logged in? And how I could associate the users name with the picture they upload?
Here is my website: s--a--p--e--z--e--e--(dot)com (take all the dashes and junk out, I just don't want this page getting crawled and showing up in search engines for my site)
Also here is the code I use for uploading pictures and the form for it:
html
<head>
<link rel="stylesheet" type="text/css" href="main.css"/>
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
Artist Name: </br>
<input type="text" name="name"/> </br>
Location:</br>
<input type="text" name="location"/> </br>
Date:</br>
<input type="text" name="date"/> </br>
Select Image: </br>
<input type="file" name="filename" size="10"/>
<input type="submit" value="Submit" name="submit"/>
</form>
</body>
</html>
<html>
<head>
<title>Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="main.css" media="screen" />
</head>
<body>
<div id="content">
<?php
include "header.php";
include "menu.php";
?>
<div style="clear: both;"></div>
<div id="works">
<h2><center>Uploaded Image</center></h2>
<?php
$ext = '';
if (isset($_FILES['filename']))
{
$filename = $_FILES['filename']['name'];
switch($_FILES['filename']['type'])
{
case 'image/jpeg':
$ext = 'jpg';
move_uploaded_file($_FILES['filename']['tmp_name'], $filename);
$image = imagecreatefromjpeg($filename);
break;
case 'image/gif':
$ext = 'gif';
move_uploaded_file($_FILES['filename']['tmp_name'], $filename);
$image = imagecreatefromgif($filename);
break;
case 'image/png':
$ext = 'png';
move_uploaded_file($_FILES['filename']['tmp_name'], $filename);
$image = imagecreatefrompng($filename);
break;
default: $ext = ''; break;
}
if($ext)
{
list($width, $height) = getimagesize($filename);
if($width > $height)
{
$new_width = 400;
$new_height =300;
}
else
{
$new_width = 300;
$new_height =400;
}
if( ($width > $new_width) OR ($height > $new_height) )
{
$ratio1 = $width/$new_width;
$ratio2 = $height/$new_height;
if($ratio1 >= $ratio2)
{
$new_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, ($new_width/$width)*$height, $width, $height);
}
else
{
$new_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, ($height/$new_height)*$width, $new_height, $width, $height);
}
}
imagejpeg($new_image, $filename);
echo "<div id='uploadtext'>We have uploaded the following image and recorded your data. Thanks for using our site!<br /></div>";
echo "<img id='uploadstyle' src=$filename />";
}
else echo "'$filename' is not an accepted image file";
}
echo "</body></html>";
if (isset($_POST['submit']) AND $ext)
{
$con=mysqli_connect("localhost","root","","imagestore");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
@$sql="INSERT INTO store (name, location, date, imagelocation)
VALUES
('$_POST[name]','$_POST[location]','$_POST[date]','$filename')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
}
?>
</div>
</div>
<div style="clear: both;"></div>
</div>
<?php
include "footer.php";
?>
</body>
</html>