Hi I have read many forums and websites that tell you how to upload an image to a server and I have managed to get this working, I can upload a file to a my server but storing the file name does work on the following example I found and I also need to create a form that allows more data to be entered to the database. I am stuck with this as a have done much php before. I have come to the end of trying different websites tutorals with no much success could anyone please help me! I need it done for a project im doing.
I am basicly trying to make a CMS that allows users to upload a photo of a band member and have information stored about them so that it can be displayed on a webpage for the public to view.
Hope that all makes sence.
Cheers
Jimmy
My Table looks like this:
Field Type Null Default id int(10) No nameMember varchar(25) No bandMember text No photo varchar(30) No aboutMember text No otherBands text No
The form I want will look like this:
<h1>Adding a new Band Member or Affiliate</h1>
<form method="post" action="addMember.php" enctype="multipart/form-data">
<p>
Please Enter the Band Members Name.
</p>
<p>
Band Member or Affiliates Name:
</p>
<input type="text" name="nameMember"/>
<p>
Please Enter the Band Members Position. Example:Drums.
</p>
<p>
Member's Position:
</p>
<input type="text" name="bandMember"/>
<p>
Please Upload a Photo in gif or jpeg format. The file name should be named after the Members name. If the same file name is uploaded twice it will be overwritten!
</p>
<p>
Photo:
</p>
<input type="file" name="filep" size=35 />
<p>
Please Enter any other information about the band member here.
</p>
<p>
Other Member Information:
</p>
<textarea rows="10" cols="35" name="aboutMember">
</textarea>
<p>
Please Enter any other Bands the Member has been in.
</p>
<p>
Other Bands:
</p>
<input type="text" name="otherBands" size=30 />
<br/>
<br/>
<input TYPE="submit" title="Add data to the Database" value="Add Member"/>
</form>
The Example that uploads an Image to the server and only, that is this:
<?
if ($_POST["action"] == "Load")
{
$folder = "images/";
move_uploaded_file($_FILES["filep"]["tmp_name"] , "$folder".$_FILES["filep"]["name"]);
echo "
<p align=center>File ".$_FILES["filep"]["name"]."loaded...";
$result = mysql_connect("localhost", "******", "*****") or die ("Could not save image name
Error: " . mysql_error());
mysql_select_db("project") or die("Could not select database");
mysql_query("INSERT into dbProfiles (photo) VALUES('".$_FILES['filep']['name']."')");
if($result) { echo "Image name saved into database
"; }
}
?>
And the Examples form I have to use is this:
<form action=addMember.php method=post enctype="multipart/form-data">
<table border="0" cellspacing="0" align=center cellpadding="3" bordercolor="#cccccc">
<tr>
<td>File:</td>
<td><input type="file" name="filep" size=45></td>
</tr>
<tr>
<td colspan=2><p align=center>
<input type=submit name=action value="Load">
</td>
</tr>
</table>
</form>
Thanks again for any help.
Ps. Images file is open for writing to.